reduceRight

The reduceRight function takes a lambda expression that takes two variables and returns a result. The difference between reduce and reduceRight is that the reduce function starts iterating from index 0 and reduceRight starts from the end of the list:

result = numbers.reduceRight { i, acc -> i + acc}
println("From end : add all elements of the list $result")

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.234.24