O'Reilly logo
  • santiago4 thinks this is interesting:

esides +, there is also a prefix -, which indicates contravariant subtyping. If Queue were defined like this:

  trait Queue[-T] { ... } 

then if T is a subtype of type S, this would imply that Queue[S] is a subtype of Queue[T] (which in the case of queues would be rather surprising!). Whether a type parameter is covariant, contravariant, or nonvariant ...


Cover of Programming in Scala, Third Edition