Syntax for existential type as a box for generic type

This is more related to either Variadic Generics or Unlock Existential Types for All Protocols.

In the first case you would have a list of heterogeneous types T0: View, T1: View, T2: View, etc. statically defined on the call site (strawman syntax ahead)

static func buildBlock<T...: View>(_ c: T...) -> some View { ... }

In the second case you would have to use an array having as Element type the existential protocol type any View

static func buildBlock(_ c: [any View]) -> some View { ... }

in which each element has access to most of the features provided by the View protocol.

1 Like