Kotlin Reflection Referencing a function


Example

Functions are first-class citizens in Kotlin. You can obtain a reference on it using double colons and then pass it to another function:

fun isPositive(x: Int) = x > 0

val numbers = listOf(-2, -1, 0, 1, 2)
println(numbers.filter(::isPositive)) // [1, 2]