Darryl Miles
03/15/2024, 7:15 PMfun myMethod(): java.util.function.Function<Int,String> {
return { value: Int ->
if(value == 42) "42" else ""
} as Function<Int,String> // heh
}
Ruckus
03/15/2024, 7:24 PMfun myMethod(): Function<Int, String> {
return Function { value: Int ->
if (value == 42) "42" else ""
}
}
Or shorter:
fun myMethod(): Function<Int, String> =
Function { if (it == 42) "42" else "" }
Darryl Miles
03/15/2024, 7:27 PM