Why method defined like “cons[B >: A](v: B)” accepts argument of type which is not supertype of A?
I am studying variance in scala right now, and I think I have a good understanding of contravariance. For example given trait List[-A] , I know that List[Int] is a supertype of List[AnyVal] . But say that I have the following trait: trait List[+A] { def cons(hd: A): List[A] } Why is cons parameter type wrong? Why it is necessary to have def cons[B >: A](v: B): List[B] ? For example: val animal_list: List[Animal] = List(tiger, dog) if we call: animal_list.cons(tiger) since Tiger <: Animal , doesn't cons ran into problem? Since B is Tiger and A is Animal and B >: A is not true. TeWu Why is cons