Chapter    11

Generic Programming

Up to this point in this book, function and method parameter and return value types have been explicitly specified. Overloading offers a way to define multiple functions that share the same signature except for varying parameter and/or return value types. And protocols provide for declaring a set of requirements that an adopting type must contractually fulfill. Yet there is one more feature of Swift that may at first feel like a mere combination of aforementioned capabilities; however, in due time, it may prove to be one the most powerful features of the language: generics. As much as the Swift standard library is made up of protocols and extensions, generic types are more abundantly used than the other two combined. ...

Get Transitioning to Swift now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.