I was very surprised by the fact that we can assign List[Nothing] To any list. Like this
val nums : List[Number] = List(1, 2, 3, 4) val nums_2 : List[Integer] = Nil; // <--- extends List[Nothing] val ints : List[Integer] = nums // error: type mismatch So, this is very confusing. In this article they said that
Because lists are covariant in Scala, this makes scala.collection.immutable.Nil an instance of
List[T], for any element of typeT.
What is that supposed to mean?