October 2018
Intermediate to advanced
370 pages
9h 15m
English
To understand the concept of the foldRight function, we'll use addition as an operation. The foldRight function adds all the elements of the list and returns the result. Just like the fold function, it takes an integer parameter and lambda expression. The difference is that the foldRight function starts executing at the end of the list:
result = numbers.foldRight(0){i,j -> i + j}println("From End : add all elements of the list " + result)
Read now
Unlock full access