Patrick Lannigan
06/08/2020, 10:58 AMfun thing(a: ((String) -> String)?) {
if (a == null) {
println("null")
} else {
println(a("hello"))
}
}
class Thing(private val a: ((String) -> String)?) {
fun thing() {
if (a == null) {
println("null")
} else {
// Reference has a nullable type '((String) -> String)?', use explicit '?.invoke()' to make a function-like call instead
println(a("hello"))
}
}
}
Reproducing the issue using the playgroundMichael de Kaste
06/08/2020, 11:19 AMa
is a function and every call to that function can produce a new value.Michael de Kaste
06/08/2020, 11:21 AMPatrick Lannigan
06/08/2020, 11:31 AMPatrick Lannigan
06/08/2020, 11:31 AMKroppeb
06/08/2020, 12:00 PM.invoke
instead of calling?Patrick Lannigan
06/08/2020, 12:05 PM.invoke()
does work.Patrick Lannigan
06/08/2020, 12:06 PMPatrick Lannigan
06/09/2020, 2:58 PM