Swift Generics (Expanded)
Show Apple's description.
Generics are one of the most powerful features of Swift, enabling you to write flexible, reusable components while maintaining static type information. Learn about the design of Swift's generics, including how to generalize protocols, leverage protocol inheritance to express the varying capabilities of related types, build composable generic components with conditional conformances, and reason about the interaction between class inheritance and generics. This expanded version of the WWDC 2018 session includes a brand-new discussion of recursive constraints.
- Very nice presentation of what Swift Generics are, why they’re better than just defining something as
Any(both from code, memory, and compiler perspective)
- How to create extensions only to some subsets of Generics (see the
- How to add constraints to Generics
- How to use Generics in protocols (via
- You can add constraints on the associatedtype:
- Protocol Inheritance
- Protocol Conformance