Arities ================================================== [test & body] Docstring ================================================== Evaluates test. If logical true, evaluates body in an implicit do.
Arities ================================================== [test & body] Docstring ================================================== Evaluates test. If logical true, evaluates body in an implicit do.
(defmacro when
"Evaluates test. If logical true, evaluates body in an implicit do."
{:added "1.0"}
[test & body]
(list 'if test (cons 'do body)))
;; See examples for "if" explaining Clojure's idea of logical true
;; and logical false.
(when (= 1 1) true)
;; => true
(when (not= 1 1) true)
;; => nil
(def has-value (when true
(println "Hello World")
"Returned Value"))
;; > Hello World
;; => #'user/has-value
has-value
;; => "Returned Value"