The difference is
def f(x: Int)(y: Int) = x + y
is a curried function. A function with two parameterlists. You can use it with just one argument, but you need to specify which one.
f(42) _ // this is short for f(42)(_: Int)
will generate a partial applied function, where the value of x
is 42
. You could also do:
f(_: Int)(42) // note: the first parameter must be used this way
This will set the value of y
to 42
.
Calling a curried function with just a few parameters will generate a partial applied function.
def f(x: Int) = (y: Int) => x + y
is a partial applied function. Here you have a function which takes one argument and returns a function which takes an argument itself.