store/[org.clojure/clojure "1.8.0"] clj::clojure.core/assert

Official Documentation

Add notes
Arities
==================================================
   [x]
   [x message]

Docstring
==================================================
  Evaluates expr and throws an exception if it does not evaluate to
  logical true.

Source

(defmacro assert
  "Evaluates expr and throws an exception if it does not evaluate to
  logical true."
  {:added "1.0"}
  ([x]
     (when *assert*
       `(when-not ~x
          (throw (new AssertionError (str "Assert failed: " (pr-str '~x)))))))
  ([x message]
     (when *assert*
       `(when-not ~x
          (throw (new AssertionError (str "Assert failed: " ~message "\n" (pr-str '~x))))))))

Example 1

Edit
(assert true)
;; => nil

(assert false)
;; => java.lang.AssertionError: Assert failed: false (NO_SOURCE_FILE:0)

(assert nil)
;; => java.lang.AssertionError: Assert failed: nil (NO_SOURCE_FILE:0)

(assert 0)
;; => nil

(assert [1 2 3])
;; => nil

(assert "foo")
;; => nil

Uses on crossclj