Now that we are warmed up, let's have some fun 😜 Kotlin supports lambdas, but lambdas are barred from using a normal return! The last expression in a lambda implicitly returns. kotlinlang.org/docs/lambdas.h…
Anyways, back to lambdas. If you really want an explicit return inside a lambda, you have to use something known as "return to labels". Essentially you give a label to the lambda and use the "return@label" syntax to return from it. kotlinlang.org/docs/returns.h…
Is that all? Of course not! Time for... drumroll... inline functions in Kotlin. Pass a lambda to an inline function, and now you can have bare returns inside a lambda 😳 Note that this is a non-local return - it returns from the calling function instead. kotlinlang.org/docs/inline-fu…
Oh, and one more thing! Kotlin has something called "single-expression functions" where the return is implied (like single expression arrow functions in Javascript, but they look so similar to assignments I have to do a double take every time I see them) kotlinlang.org/docs/functions…
We're done - this is all I know about returns in Kotlin 😀 Maybe I am getting old, maybe its just my Lisp brain at work. But things like this have made Kotlin very hard for me to grok. The docs at kotlinlang.org are wonderful, but I wish there were less of it.
