8 ms·
Why doesn't a protocol conform to itself?
by nicky0 7y ago
Why doesn't a protocol conform to itself?
- skohan 7y agoIn many cases it doesn't make sense. For instance, what if your protocol contains a static member? protocol P { static var x: Int { get } } Here `let x = P.x` doesn't make any sense, because it's only the type implementing the protocol which has that member. However this would be possible: func f() -> some P { ... } let p = f() let x = type(of:p).x because in this case p has a concrete type, we just don't know what it is.