exercises-stdlib
exercises-stdlib copied to clipboard
Type Variance Exercise
The original AboutTypeVariance koan defined the following class hierarchy:
class Fruit
abstract class Citrus extends Fruit
class Orange extends Citrus
class Tangelo extends Citrus
class Apple extends Fruit
class Banana extends Fruit
I feel, adding this information to the type variance exercise would help readers fully understand the examples. Namely, in the following contravariance example, it is important to know that Citrus
is a superclass of both Orange
and Tangelo
.
val orangeBasket: MyContainer[Orange] = new MyContainer[Citrus](new Tangelo)