让我们定义f
一个支持柯里化的函数:
def f(a: Int)(b: Int) = a + b
此代码无法编译
def g= f(1)
<console>:10: error: missing arguments for method f;
follow this method with `_' if you want to treat it as a partially applied function
def g= f(1)
我找到了这两种解决方法:
scala> def h = f(1) _
h: Int => Int
scala> def i : Int => Int = f(1)
i: Int => Int
但我不明白为什么推理引擎在这种微不足道的情况下需要帮助?