Generics and type erasure
You have an Iterator protocol with getNext() and hasNext(), and you want to change it from Int-only to generic with associatedtype Element. After the change, building an [Iterator] array no longer compiles. Why?
You have an Iterator protocol with getNext() and hasNext(), and you want to change it from Int-only to generic with associatedtype Element. After the change, building an [Iterator] array no longer compiles. Why?
A protocol with an associated type isn't a complete type until Element is filled in, so it can't be an array's element type directly, and even boxed as any Iterator the members that use Element are restricted.
SwiftShort answerAdvanced
From the caller's side, what's the difference between func make() -> some Shape and func…
#generic #any
SwiftShort answerBasics
What can Any, AnyObject, and NSObject each hold?
#any
SwiftShort answerBasics
During code review you find the same logic overloaded per type: func larger(_ a: Int, _…
#any
ArchitectureShort answerAdvanced
You have three network clients for the auth server, product server, and payment server…
#generic