Trying to convert some java code to kotlin, given the following method
public class Option<T> {
public <U> Option<U> map(Function<T, U> mapper) {
throw new IllegalStateException();
}
}
kotlin conversion will give this

I cannot understand whats the problem here, and how do i create equivalent method in kotlin? (thats the java.util.Function)
P.S. could not come up with some better question summary... feel free to change.
To use java.util.function.Function, you have to import it explicitly:
import java.util.function.Function
That's because by default Function is resolved to kotlin.Function.
But there are function types in Kotlin, and more idiomatic implementation would be
fun <U> map(mapper: (T) -> U): Option<U> {
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With