exercises-stdlib icon indicating copy to clipboard operation
exercises-stdlib copied to clipboard

Type Variance Exercise

Open blogscot opened this issue 7 years ago • 0 comments

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)

blogscot avatar Jun 20 '17 14:06 blogscot