Save 40% on books and eBooks + 70% on videos now through May 31*—use code PROGRAM. Shop now.
Additional sample videos, individual lessons and other formats are available here.
Register your product to gain access to bonus material or receive a coupon.
Rather than writing separate code to perform identical tasks on different types (e.g., summing an Array of integers vs. summing an Array of floating-point values), generics enable you to write the code once and use placeholders to represent the type(s) of data to manipulate. In this lesson, you explore the motivation for generics in Swift and learn how to create your own generic functions, methods and types.