Scala has the following built-in operators (methods/language elements with predefined precedence rules):
Type | Symbol | Example |
---|---|---|
Arithmetic operators | + - * / % | a + b |
Relational operators | == != > < >= <= | a > b |
Logical operators | && & || | ! | a && b |
Bit-wise operators | & | ^ ~ << >> >>> | a & b , ~a , a >>> b |
Assignment operators | = += -= *= /= %= <<= >>= &= ^= |= | a += b |
Scala operators have the same meaning as in Java
Note: methods ending with :
bind to the right (and right associative), so the call with list.::(value)
can be written as value :: list
with operator syntax. (1 :: 2 :: 3 :: Nil
is the same as 1 :: (2 :: (3 :: Nil))
)