July 2023
Intermediate to advanced
670 pages
17h 13m
English
Earlier in this book, you learned about a type of polymorphism called parametric polymorphism that allows you to write a single implementation of a function that can work with many different types using type variables. This style of polymorphism is when you are concerned with data structures and the shape of the data you are working with, but don’t need to directly inspect values. Unfortunately, parametric polymorphism falls short when we need to deal with the polymorphic values in a non-generic way. As soon as we need to carry out specific operations on a polymorphic value, we run into the problem that our operations depend on what type the value happens to be.
Object-oriented programming languages let you solve this ...