Scala 中间列表中的列表#()
我可以使用从Scala 中间列表中的列表#(),scala,Scala,我可以使用从列表中获取index=2项 但是,为什么我不能做到以下几点 scala> List(1,2,3).(2) <console>:1: error: identifier expected but '(' found. List(1,2,3).(2) ^ scala>列表(1,2,3)。(2) :1:错误:应为标识符,但找到了“(”。 列表(1,2,3)。(2) ^ 您不需要 scala> List(1,2,3
列表中获取index=2
项
但是,为什么我不能做到以下几点
scala> List(1,2,3).(2)
<console>:1: error: identifier expected but '(' found.
List(1,2,3).(2)
^
scala>列表(1,2,3)。(2)
:1:错误:应为标识符,但找到了“(”。
列表(1,2,3)。(2)
^
您不需要
scala> List(1,2,3)(2)
res1: Int = 3
绝对不是我最好的问题之一。
scala> List(1,2,3)(2)
res1: Int = 3