I tried to learn higher order functions from the first example of this video . Here is my code and output.
the code
fun lowercase(value: String) = value.toLowerCase()
fun higherOrder(value:String, op: (String) -> String) : String {
println("Executing higher order fun $op")
return op(value)
}
fun main(args: Array<String>) {
println(higherOrder("HELLO", ::lowercase))
println(higherOrder("hello", {it -> lowercase(it)}))
println(higherOrder("HeLlo", { x -> lowercase(x) }))
println(higherOrder("Hello", { lowercase(it) }))
}
Output
Executing higher order fun function lowercase (Kotlin reflection is not available)
hello
Executing higher order fun Function1<java.lang.String, java.lang.String>
hello
Executing higher order fun Function1<java.lang.String, java.lang.String>
hello
Executing higher order fun Function1<java.lang.String, java.lang.String>
hello
Process finished with exit code 0
So my question is: why print Kotlin's Reflection is not available ?
source
share