如何将currying应用于scala中的现有正常函数

时间:2016-08-06 09:36:39

标签: scala

我在scala中有以下功能

现在我想将currying应用于此功能

scala> def add(x:Int,y:Int) = x+y
add: (x: Int, y: Int)Int

scala> val addCurried = Function.curried(add_)
 <console>:7: error: value curried is not a member of object Function
   val addCurried = Function.curried(add_)
                             ^

 scala> val addCurried = Function.curried(add _)
 <console>:8: error: value curried is not a member of object Function
   val addCurried = Function.curried(add _)

这里出了什么问题?如何将currying应用于scala中的exixting函数

1 个答案:

答案 0 :(得分:1)

val addCurried = (add _).curried

如您所见[{3}},curried对象上没有Function方法。