Logo

Programming-Idioms

History of Idiom 37 > diff from v37 to v38

Edit summary for version 38 by Debaran:
[Scala] More idiomatic way

Version 37

2019-02-02, 05:02:25

Version 38

2019-02-02, 06:14:44

Idiom #37 Currying

Transform a function that takes multiple arguments into a function for which some of the arguments are preset.

Idiom #37 Currying

Transform a function that takes multiple arguments into a function for which some of the arguments are preset.

Extra Keywords
curry
Extra Keywords
curry
Code
def add(x: Int)(y: Int) = x + y
def add5 = add(5)_
Code
def add(x: Int)(y: Int) = x + y
val add5 = add(5)_
Comments bubble
With multiple parameter lists. (add5 takes the 1 parameter of the other parameter list)
Comments bubble
With multiple parameter lists. (add5 takes the 1 parameter of the other parameter list)