https://kotlinlang.org logo
#announcements
Title
# announcements
k

karelpeeters

09/12/2017, 10:10 AM
Try
obj?.let { ... } ?: run { ... }
.
g

geatmo

09/12/2017, 11:29 AM
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

karelpeeters

09/12/2017, 11:30 AM
You're right, if you don't want that you could use
also
instead of
let
.
g

geatmo

09/12/2017, 11:31 AM
okay, cool.. just wanted to make sure I understood correctly.. 🙂
2 Views