Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 中间列表中的列表#()_Scala - Fatal编程技术网

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