我有一个带有默认参数的无副作用的方法,我想在没有括号的情况下调用,例如:
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
Run Code Online (Sandbox Code Playgroud)
这是故意的还是暂时的限制?
scala ×1