让
def f(i:Int)(j:Int) = i + j
等等
f(1) _
Int => Int = <function1>
然而,
val f: (Int)(Int) => Int = (a:Int)(b:Int) => a + b // wrong
即error: ';' expected but '(' found.
如何声明val f
?
答案 0 :(得分:2)
这是你在找什么?
scala> val f: Int => Int => Int = a => b => a + b
f: Int => (Int => Int) = <function1>
scala> f(1)
res7: Int => Int = <function1>
scala> f(1)(2)
res8: Int = 3