Confused by the parameters of higher order functions in Kotlin
In Kotlin, I write the following code, which calls the fold function.
fun operation(acc: Int, next: Int): Int {
return acc * next
}
val items = listOf(1, 2, 3, 4, 5)
println(items.fold(1, ::operation))
In the 5th line of the above code, the fold function uses the operation function.
This is reasonable because the fold function is declared to accept a function reference or lambda that takes exactly TWO parameters(3rd line of the following fold implementation from the Kotlin stdlib...