Tuesday, 19 February 2008

Not using = equals in a Scala method definition

If the return type of a method is Unit,

def add(b: Byte): Unit = sum += b

then it can be written like this instead:

def add(b: Byte) { sum += b }

No comments: