Reference to method of a particular instance in Kotlin

Since Kotlin 1.1, you can use bound callable references to do that:

val f = a::getItem

list.forEach(myObject::myMethod)

Earlier Kotlin versions don’t have this feature and require you to make a lambda every time except for these simple cases.

Leave a Comment