How to go from `Function<T,R>?` to `((T) -&g...
# getting-started
a
How to go from
Function<T,R>?
to
((T) -> R)?
I used an extension property
val Function<T,R>.lambda: ((T) -> R) get() = this::apply
and use it like
func?.lambda
v
Function<T,R>?
to
((T) -> R)?
are the same type, you shouldn't need converting one to the other
a
Maybe I'm missing something here with generics then. do i need to specify in/out somewhere?
the reverse also gives similar type mismatch message
Copy code
fun <T,R> bar(func: ((T) -> R)? = null) {
    foo<T,R>(func)
}

fun <T,R> foo(func: java.util.function.Function<T, R>? = null) {
    bar<T,R>(func)
}
k
What about
bar<T,R>{ func.apply(it) }
?