In the previous recipes, we investigated how we can use generics within types and functions. Now we will round off our journey through generics in Swift by looking at how Swift can be used in protocols to produce abstract interfaces, while maintaining strongly typed requirements that allow for a more descriptive model.
Using generics with protocols
Getting ready
In this recipe, we will build a model for a transport app in the UK with the goal of providing the distance that a journey may take over different methods of transport.
How to do it...
At the outset, it may not...