• Infix notation `x`

*op* `y`

is `x.`

*op*`(y)`

, postfix notation `x`

*op* is `x.`

*op*`()`

• Only `+ - ! ~`

can be prefix—define method `unary_`

*op*

• Assignment `x`

*op*`=y`

is `x = x`

*op* `y`

unless defined separately

• Precedence depends on *first* character, except for assignments

• Right associative if *last* character is a colon `:`

• `x(i) = x(j)`

is `x.update(i, x.apply(j))`

• There is no `++`

or `--`

for numbers. Use `x += 1; y -= 1`

• Use `x == y`

to compare objects—it calls `equals`

def triple(x: Int) = 3 * x // Parameter name: Typeval f = (x: Int) => 3 * x // Anonymous function(1 to 10).map(3 * _) // Function with anonymous parameterdef greet(x: Int) { // Without =, return ...

Start Free Trial

No credit card required