Monday, June 17, 2013

Default parameter values in Scala

I've just discovered funny thing about default parameter values in Scala. If you call a function without parenthesis default values can't be applied and compilation fails. If you have such function:
def hello(name: String = "world") {
    println("hello, "+name)
}
Then this would fail to compile:
hello
and this would compile and run well:
hello()

No comments:

Post a Comment