user=> (when (= 1 1) true) true user=> (when (not= 1 1) true) nil
user=> (def has-value (when true (println "Hello World") "Returned Value")) Hello World #'user/has-value user=> has-value "Returned Value"
;; See examples for "if" explaining Clojure's idea of logical true ;; and logical false.
Evaluates test. If logical false, evaluates body in an implicit do.
bindings => binding-form test When test is true, evaluates body wi
Please see http://clojure.org/special_forms#if
(defmacro when "Evaluates test. If logical true, evaluates body in an implicit do." {:added "1.0"} [test & body] (list 'if test (cons 'do body)))
Comments top
No comments for when. Log in to add a comment.