Post

Replies

Boosts

Views

Activity

Sample Code from WWDC video does not compile.
The sample code below does not compile: protocol RequestProtocol { associatedtype Input associatedtype Output func evaluate(_: Input) -> Output } struct Evaluator<each Request: RequestProtocol> { let item: (repeat each Request) func query(_ input: repeat (each Request).Input) -> (repeat (each Request).Output) { return (repeat (each item).evaluate(each input)) } } Code causes two compiler errors: 'each' cannot be applied to non-pack type '(repeat each Request)' Pack expansion requires that 'each Request' and '()' have the same shape Please advise.
0
2
916
Jun ’23
Error: "Generic types with parameter packs are experimental"
Code below from the video: Generalize APIs with parameter packs protocol RequestProtocol { associatedtype Input associatedtype Output func evaluate(_ input: Input) -> Output } struct Evaluator<each Request: RequestProtocol> { var item: (repeat each Request) func query( _ input: repeat (each Request).Input ) -> (repeat (each Request).Output) { return (repeat (each item).evaluate(each input)) } } The Evaluator declaration causes a compiler error, "Generic types with parameter packs are experimental". Is there a switch or flag to enable use of parameter packs?
3
0
1.2k
Jun ’23