我写了以下代码:
class Animal
class Bird extends Animal
val animalList = List(new Animal, new Animal)
new Bird :: animalList
该::
方法的实现如下所示:
def ::[B >: A] (x: B): List[B] =
new scala.collection.immutable.::(x, this)
我预计返回类型是List[Bird]
. 为什么呢List[Animal]
?