I am trying to understand the reflection. I have the following code:
fun main(args: Array) {
println(lengthL1())
println(lengthL2(s))
println(lengthL1.get()) // Error
println(lengthL2.get(s)) // Errorprintln(lengthNL1.get()) println(lengthNL2.get(s)) println(lengthNL1()) println(lengthNL2(s))
}
val s = “1234”
val lengthL1: () → Int = s::length
val lengthL2: (String) → Int = String::lengthval lengthNL1 = s::length
val lengthNL2 = String::length
Why I cannot call the get
(See Error comments) when I declare the lambda?
Is there any difference between lengthL1
and lenghtNL1
?
You can see it in stackoverflow also.