clojure.core/assert¶
Evaluates expression x and throws an AssertionError with optional message if x does not evaluate to logical true.
Assertion checks are omitted from compiled code if 'assert' is false.
Examples¶
Note by Steve Kuo¶
The documentation ("... and throws an exception if ...") is incorrect. It throws AssertionError which an Error and not an Exception. They both extend Throwable but Error is not an Exception.
Note by didibus¶
By default, assertions are turned on, since the value of *assert* defaults to true in Clojure.
Note by taehee-kim-sherpas¶
in shadow-cljs, All assertions are removed in release mode by default. In other words, assert is false in release mode. (see :elide-asserts option) It is applied to schema libraries like malli, malli.core/assert is removed on release mode.
See also¶
Content from the matching ClojureDocs page, with authors credited on each contribution.