July 2018
Intermediate to advanced
242 pages
8h 6m
English
Let's explore how to use the curried() function in action. In the following example we are going to call curried() on the following function instance which is responsible for computing a sum of three integers:
fun sum(a: Int, b: Int, c: Int): Int = a + b + c
In order to obtain a curried form of the sum() function, we have to invoke the curried() function on its reference:
::sum.curried()
Then we can invoke the curried sum function in the following way:
val result: Int = ::sum.curried()(1)(2)(3)
In the end, the result variable is going to be assigned an integer value equal to 6.
Read now
Unlock full access