Scala的List.cons方法在哪里?

时间:2019-09-11 13:18:14

标签: scala

Scala的List.cons在哪里?我在设置中找不到它。

scala> List.::
<console>:12: error: value :: is not a member of object List
       List.::
            ^

scala> List.cons
<console>:12: error: value cons is not a member of object List
       List.cons
            ^

如果我输入List。[tab]以自动完成,我会得到

scala> List.
!=   ->                    ReusableCBF    canBuildFrom   ensuring   fill        hashCode       ne           notifyAll      tabulate     wait
##   ==                    apply          concat         eq         formatted   isInstanceOf   newBuilder   range          toString     →
+    GenericCanBuildFrom   asInstanceOf   empty          equals     getClass    iterate        notify       synchronized   unapplySeq

1 个答案:

答案 0 :(得分:5)

它在类List上,而不在对象List上。

scala> List(1).::
   def ::[B >: Int](elem: B): List[B]