Try `obj?.let { ... } ?: run { ... }`.
# announcements
k
Try
obj?.let { ... } ?: run { ... }
.
g
Couldn't there be cases, where both paths might be executed? If the last statement in the
let
block would evaluate to
null
, that would make
let
itself return
null
and thus trigger the elvis operator.. or am I missing something here?
k
You're right, if you don't want that you could use
also
instead of
let
.
g
okay, cool.. just wanted to make sure I understood correctly.. 🙂