assert
Assert that a condition is true; throw an error if not.
Syntax
Section titled “Syntax”assert(expression)assert(expression, msg)assert(expression, msgId, msg, ...)Description
Section titled “Description”If expression evaluates to false, throws an error with the supplied message (or a default message). Use to enforce preconditions and invariants. Errors thrown by assert propagate normally and can be caught with try/catch.
Examples
Section titled “Examples”assert(x > 0, 'x must be positive')assert(size(A) == size(B), 'matrices must match')