Stuff about software development, agile and testing

Monday, January 14, 2008

Scala: Surprise Part oNe

Ruby is a language of least surprises but I am not sure whether I can say that for Scala yet. I have already encountered some of them, here is one example

You can define method without '()'

def height: Int = 0 //This is a valid method

def width(): Int = 0 //This is valid too

Now you can invoke 'width' method with and without parenthesis but you cannot do that for height method.


Update: The Scala convention is, use '()' for parameter less method if it has side effects otherwise don't