kotlin higher order functions
snippet in kotlin

kotlin closures

user5996

They are called lambdas ;)

kotlin higher order functions

user4238

fun main() {
    higherOrderSequence(5, ::square)

}

fun higherOrderSequence(num: Int, myFunc: (Int) -> Int) {
    // A function declared as an argument must specify input and return type

    for (x in 1..num) {
        print("${myFunc(x)} ")
    }
    println()
}

fun square(num: Int):Int {
    return num * num
}