Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij does not recognize Scala List operator

Here is the intellij warning :

enter image description here

When overing "::" Intellij display this message : Cannot resolve symbol ::

I have scala + sbt plugins correctly installed.

How can i fix this error ?

like image 982
Manel Avatar asked May 16 '15 14:05

Manel


1 Answers

Your code is incorrect : :: is a method on List, not on Integer. Your last element must be an instance of 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.

From the Scala Specification (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.

like image 195
Marth Avatar answered Oct 25 '22 06:10

Marth