https://kotlinlang.org logo
e

Eugenio

07/08/2016, 11:21 AM
Question: say that I have the following inlined function, used like below; is it possible to extract the lambda with the
return
in a way that can be reused in multiple places instead of specifying it every time? I know I could wrap all of it in another inlined function but I'd like to do it locally
Copy code
inline infix fun <T> T?.or(or: () -> T): T = this ?: or()

supportContext = intent.supportContext or { finish(); return }
Would like to do something like:
Copy code
val finish = { finish(); return }
supportContext = intent.supportContext or finish