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
^
Run Code Online (Sandbox Code Playgroud)
如果我输入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
Run Code Online (Sandbox Code Playgroud)
它在类上List,而不在对象上List。
scala> List(1).::
def ::[B >: Int](elem: B): List[B]
Run Code Online (Sandbox Code Playgroud)