why is it that when I have a `when` like this one ...
# getting-started
o
why is it that when I have a
when
like this one
Copy code
when (locationState) {
    !is LocationState.Set -> {}
    is LocationState.Disabled -> onLocationDisabled()
    is LocationState.NotGranted -> onLocationNotGranted()
    else -> Unit
}
all the conditions after the first
!is LocationState.Set
are now unreachable?
a
Logically, if the 2nd and 3rd condition were true, then the first condition would also have to be true, since if the
locationState
were
Disabled
or
NotGranted
, then it would also not be
Set
.
o
it can’t read English!
that’s human reasoning
it can be Not Set because it is disabled or not granted
a
It has to be
!Set
if it is
Disabled
or
NotGranted
o
yes
aah
ok ok
a
:)
o
🙂