check
Validates a state precondition.
Returns normally when value is true. On failure, the exception message is Check failed.. Use the lazy-message overload to provide more context.
Parameters
value
condition that must be true.
See also
Throws
if value is false.
Validates a state precondition, computing a message only on failure.
When value is true, lazyMessage is never called. Otherwise it runs once and its result is converted using toString(). Exceptions from the callback or conversion propagate unchanged. The inline callback supports non-local returns.
check(count >= 0) { "Negative count: $count" }Content copied to clipboard
Parameters
value
condition that must be true.
lazyMessage
callback producing a non-null message value on failure.
Throws
if value is false and message construction completes normally.