What is the difference between def f(x: Int)(y: Int) = x + y
and def f(x: Int) = (y: Int) => x + y
?
The REPL doesn’t seem happy when I treat the former the same as the latter:
scala> def f(x: Int)(y: Int) = x + y
f: (x: Int)(y: Int)Int
scala> f(42)
<console>:9: error: missing arguments for method f;
follow this method with `_' if you want to treat it as a partially applied function
f(42)
^
scala> def f(x: Int) = (y: Int) => x + y
f: (x: Int)Int => Int
scala> f(42)
res2: Int => Int = <function1>
What are the exact differences and when should I use which form?