Chapter 7. Generics
This chapter covers
- How and when to write generic code
- Understanding how to reason about generics
- Constraining generics with one or more protocols
- Making use of the Equatable, Comparable, and Hashable protocols
- Creating highly reusable types
- Understanding how subclasses work with generics
Generics are a core component of Swift, and they can be tricky to understand at first. There is no shame if you’ve been staying away from generics, perhaps because they are sometimes intimidating or confusing. Like a carpenter can do work without a hammer, so can you develop software without generics. But making generics part of your regular software routine sure does help, because by using generics you can create code that works ...
Get Swift in Depth now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.