Avatar
↓この話おもしろい。
Hamish provides a complete explanation on StackOverflow as to why an existential of type P does not conform to the protocol P. The following example from that answer demonstrates the point with an initializer requirement:
protocol P { init() } struct S: P {} struct S1: P {} extension Array where Element: P { mutating func appendNew() { // If Element is P, we cannot possibly construct a new instance of it, as you cannot // construct an instance of a protocol. append(Element()) } } var arr: [P] = [S(), S1()] // error: Using 'P' as a concrete type conforming to protocol 'P' is not supported arr.appendNew()
(edited)