5

我有一个带有默认参数的无副作用方法,我想在没有括号的情况下调用它,例如:

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

这是故意的,还是只是暂时的限制?

4

1 回答 1

9

这可能是故意的,因此您不会让参数块消失在您身上:

def foo(x: Int = 2)(y: Int = 4) = x*y

foo(3)    // What does this mean???
于 2013-01-03T18:16:31.527 回答