Let's make our own type!
You saw how to parameterize the entire code.
Try change MyType
from Int
to String
.
This seem simple but it is a building block required to understand generic type later.
If you want to start now, try to replace MyType
by the following code:
type SubType = Int type MyType = List[SubType]Do you see how you can combine types together ? Like Lego !
List
can be parameterized, we used it with Int
and String
in the past, but you can use any type you want.