Is there a natural way to have a multiple sentence block as the right side of an elvis operator? So far I can type only a single expression and if I add curly braces it is detected as a lambda. I have implemented
Any?.orElse(block: () -> Nothing)
which works for the purpose like a charm but then I wonder why there isn't anything like that in the language itself or the stdlib, maybe I am missing something?
p
Pavlo Liapota
05/08/2019, 6:11 AM
Copy code
expression ?: run {
defaultValue
}
p
Pere Casafont
05/08/2019, 6:12 AM
omg thank you!
p
Pavlo Liapota
05/08/2019, 6:12 AM
no problem 🙂
p
Pere Casafont
05/08/2019, 6:14 AM
at least I had a couple minutes of fun creating that useless function 👽