O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generics and Associated Type Protocols

Generics enable us to write flexible and reusable functions, methods, and types that can work with any type. This chapter explains how to define and use Generics and introduces the problems that can be solved with Generics in the Swift programming language with examples.

This chapter will cover the following topics with coding examples:

  • Generic functions and methods
  • Generic parameters
  • Generic type constraints and where clauses
  • Generic data structures
  • Associated type protocols
  • Type erasure
  • Extending Generic types
  • Subclassing Generic classes

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required