Kotlin has these 2 features and I think there're no significant differences between these two regardless of :
// lambda
val toUpper = { value: String ->
if (value.isEmpty()) "empty value"
else value.toUpperCase()
}
// anonymous func
val toUpper = fun(value: String): String {
if (value.isEmpty()) return "empty value"
else return value.toUpperCase()
}
I'm still digesting these features and hope you guys can help me pass through it. Thanks.
Two differences according to Kotlin Reference:
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