[英]Intellij does not recognize Scala List operator
Here is the intellij warning : 这是intellij警告:
When overing "::" Intellij display this message : Cannot resolve symbol :: 当覆盖“::”时,Intellij显示以下消息:无法解析符号::
I have scala + sbt plugins correctly installed. 我正确安装了scala + sbt插件。
How can i fix this error ? 我该如何解决这个错误?
Your code is incorrect : ::
is a method on List
, not on Integer
. 您的代码不正确
::
是List
上的方法,而不是Integer
上的方法。 Your last element must be an instance of List
. 您的最后一个元素必须是
List
的实例。
Either of those will work : 这些都可以工作:
val otherList = 3::2::List(3)
or 要么
val otherList = 3::2::3::Nil
Note that ::
is called on List
and not the Integer
because it is right-associative. 请注意
::
在List
上调用,而不是Integer
因为它是右关联的。
From the Scala Specification ( Infix Operations , 6.12.3) : 来自Scala规范 ( Infix Operations ,6.12.3):
The associativity of an operator is determined by the operator's last character.
操作员的关联性由操作员的最后一个字符决定。 Operators ending in a colon ':' are right-associative.
以冒号':'结尾的运算符是右关联的。 All other operators are left-associative.
所有其他运算符都是左关联的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.