curry2<FirstParameter, SecondParameter, ReturnType> function
ReturnType Function(SecondParameter second) Function(FirstParameter first)
curry2<FirstParameter, SecondParameter, ReturnType>(
- ReturnType function(
- FirstParameter first,
- SecondParameter second
Converts a binary function into a unary function that returns a unary function.
Enables the use of partial application of functions. This often leads to more concise function declarations.
The generic types are in this order:
- Type of the first function parameter
- Type of the second function parameter
- Return type of the function
final addFunction = (int a, int b) => a + b;
final add = curry2(addFunction);
[1, 2, 3].map(add(1)) // returns [2, 3, 4]
Implementation
ReturnType Function(SecondParameter second) Function(FirstParameter first)
curry2<FirstParameter, SecondParameter, ReturnType>(
ReturnType Function(FirstParameter first, SecondParameter second) function,
) =>
(FirstParameter first) =>
(SecondParameter second) => function(first, second);