Scala Language Operator Precedence


Postfix() []Left to right
Unary! ~Right to left
Multiplicative* / %Left to right
Additive+ -Left to right
Shift>> >>> <<Left to right
Relational> >= < <=Left to right
Equality== !=Left to right
Bitwise and&Left to right
Bitwise xor^Left to right
Bitwise or|Left to right
Logical and&&Left to right
Logical or||Left to right
Assignment= += -= *= /= %= >>= <<= &= ^= |=Right to left
Comma,Left to right

Programming in Scala gives the following outline based on the 1st character in the operator. E.g. > is the 1st character in the operator >>>:

(all other special characters)
* / %
+ -
= !
< >
(all letters)
(all assignment operators)

The one exception to this rule concerns assignment operators, e.g. +=, *=, etc. If an operator ends with an equal character (=) and is not one of the comparison operators <=, >=, == or !=, then the precedence of the operator is the same as simple assignment. In other words, lower than that of any other operator.