Chapter 17. Type Parameters
Topics in This Chapter L2
In Scala, you can use type parameters to implement classes and functions that work with multiple types. For example, an Array[T]
stores elements of an arbitrary type T
. The basic idea is very simple, but the details can get tricky. Sometimes, you need to place restrictions on the type. For example, to sort elements, T
must provide an ordering. Furthermore, if the parameter type varies, ...
Get Scala for the Impatient, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.