Suppose I have high order function that accepts a lambda as a parameter like this:
fun getNum(op: () -> Int) = op()
And a function that returns a number:
fun getTen() = 10
In the main function I can call the getNum() function like this
fun main(args: Array<String>){
val x = 50
val a = getNum(::getTen) // a == 10
val b = getNum{x} // this works and b == 50
}
Why does passing a varibale instead of lambda works? Any idea? Thanks.