https://kotlinlang.org logo
#getting-started
Title
# getting-started
k

Karlo Lozovina

09/02/2020, 1:01 PM
is there something like
TODO("reason")
but meant just for unreachable `if`/`when` branches? (for example like Rust has
unreachable!
macro do designate code paths that can't be taken)
d

diesieben07

09/02/2020, 1:08 PM
throw IllegalStateException("description of why this is an illegal state")
is what I do usually.
k

Karlo Lozovina

09/02/2020, 1:10 PM
I think I'll do that... that's what
error("reason")
does, right?
1
d

diesieben07

09/02/2020, 1:11 PM
Yes! I didn't even know about that one
m

Michael de Kaste

09/02/2020, 1:16 PM
we usually go for the more specific throwing of illegalstate/arguments, but error("reason") is fine too
n

nanodeath

09/02/2020, 1:54 PM
I usually use AssertionError for branches that are truly unreachable