February 2018
Intermediate to advanced
552 pages
13h 46m
English
In Scala, any operator ending with : (a colon) is right associative. Let's explore this in more detail with some examples.
In simple words, right associative means evaluate expressions from right to left, and left associative means evaluate expressions from left to right.
Take our previous example again:
scala> numbersList = numbersList :: 4
<console>:11: error: value :: is not a member of Int
numbersList = numbersList :: 4
Here, we are getting a value :: is not a member of Int error owing to the right associative rule.
When we execute the numbersList :: 4 expression, it will interpret it in this way:
Expression = numbersList :: 4
As per the right associative rule, the Scala compiler starts evaluation of this expression ...
Read now
Unlock full access