O'Reilly logo

Swift Programming: The Big Nerd Ranch Guide by John Gallagher, Matthew Mathias

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

For the More Curious: Parametric Polymorphism

In Chapter 15, you learned about class inheritance. Any function that expects an argument of a class can also accept arguments that are subclasses of that class. This ability to accept either a class or any subclass of it is often referred to as polymorphism, but is more accurately known as runtime polymorphism or subclass polymorphism. Polymorphism, meaning many forms, allows you to write a single function that can accept different types.

Runtime polymorphism is a powerful tool, and the frameworks Apple provides for development use it frequently. Unfortunately, it also has drawbacks. Classes that are related by inheritance are tied together tightly: It can be difficult to change one ...

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