Yeah, I know those already. But neither `requireXX...
# announcements
d
Yeah, I know those already. But neither
requireXXX
(for "check incoming arguments") nor
checkXXX
(for "check if this method may be called right now") are appropriate for an "this internal state must be like this or I made a programmer error".
a
Why isn’t
checkXXX
appropriate in your opinion? It throws an
IllegalStateException
, and if you look at the samples https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/samples/test/samples/misc/preconditions.kt they use it to check state.
d
If you read the Javadocs on
IllegalStateException
it becomes clear:
Signals that a method has been invoked at an illegal or inappropriate time.
That is not the case, it was fine to invoke the method here, but something inside the method went wrong, due to a program bug.