This playground tries to explain type erasure by going through three erasure types. In the examples a Box
protocol that contains an InsideType
is used.
The type erasure examples:
- Creating a wrapper class that can hold a specific
Box
ofInt
(Not really type erasure) - Creating a wrapper class that can hold any
Box
withInsideType
ofInt
(Boxes of Ints) - Creating a wrapper class that can hold any
Box
regardless of it'sInsideType
(Boxes of Any)