when-let

macrosince v0.0-927imported clojure.core/when-letEdit
(when-let bindings & body)

Details:

When test is logical true, evaluates body with the value of test bound to x.


See Also:


Source docstring:
bindings => binding-form test

When test is true, evaluates body with binding-form bound to the value of test
Source code @ clojure:src/clj/clojure/core.clj
(defmacro when-let
  {:added "1.0"}
  [bindings & body]
  (assert-args
     (vector? bindings) "a vector for its binding"
     (= 2 (count bindings)) "exactly 2 forms in binding vector")
   (let [form (bindings 0) tst (bindings 1)]
    `(let [temp# ~tst]
       (when temp#
         (let [~form temp#]
           ~@body)))))