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
答案 0 :(得分:5)
它在类List
上,而不在对象List
上。
scala> List(1).::
def ::[B >: Int](elem: B): List[B]