just want to confirm this kind of code is ok `when...
# announcements
d
just want to confirm this kind of code is ok
when (foo?.bar) {..}
- I can't see why it wouldn't be but just want to make sure about the null
y
It’s okay, just remember that
null
is one of the possible values of
foo?.bar
(and so must be handled in the
when
clause if not using
else
).
d
thanks
but if i just want to ignore the null, I can't just leave it out of
->
? the IDE doesn't complain
👌 1
y
One of the trickiest thing about Kotlin
when
is that it can be used either as an expression or a statement
If it’s used as a statement, the compiler won’t perform exhaustive checks (i.e. it won’t complain about missing arms)