Entry 1937

scala Operator Overloading, no . or ()

   

Submitted by anonymous on June 22, 2009 at 3:22 a.m.
Language: Scala. Code size: 200 bytes.

//x will be 3
val x = 1 + 2

//exactly the same
val y = 1.+(2)

//method
def isEven(n: Int) = (n % 2) == 0

//look mom, no dots or parentheses 
List(1, 2, 3, 4) filter isEven foreach println

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).