Through currying, Scala allows methods to be defined with multiple parameter lists. Consider the following two method definitions:
def regular(x: Int, y: Int, z: Int) = x + y + z def curried(x: Int)(y: Int)(z: Int) = x + y + z
Both methods compute the same result when given identical values for their corresponding arguments:
scala> regular(1, 2, 3) res0: Int = 6 scala> curried(1)(2)(3) res1: Int = 6
Despite this similarity, the curried method is fundamentally different from the regular one: the invocation of curried represents three consecutive function invocations.
Scala also supports default arguments, which significantly reduces the need for method overloading. Furthermore, by combining default arguments ...