Reputation: 1544
I have a side-effect free method with default arguments that I'd like to invoke without parenthesis, e.g.:
scala> def foo(x: Int = 1) = 42
foo: (x: Int)Int
scala> foo
<console>:9: error: missing arguments for method foo in object $iw;
follow this method with `_' if you want to treat it as a partially applied function
foo
^
scala> foo()
res3: Int = 42
Is this intentional, or just a temporary limitation?
Upvotes: 5
Views: 553
Reputation: 167891
This is probably intentional so you don't get parameter blocks disappearing on you:
def foo(x: Int = 2)(y: Int = 4) = x*y
foo(3) // What does this mean???
Upvotes: 9