March 2012
Intermediate to advanced
384 pages
8h 36m
English
• 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 xop=y is x = xop 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: ...
Read now
Unlock full access