Kotlin has these 2 features and I think there're no significant differences between these two regardless of :
- syntax
// 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()
}
- flexibility to use return statement on anonymous function
I'm still digesting these features and hope you guys can help me pass through it. Thanks.