macro | since v0.0-927 | imported clojure.core/when-let | Edit |
(when-let bindings & body)
When test
is logical true, evaluates body
with the value of test
bound to
x
.
bindings => binding-form test When test is true, evaluates body with binding-form bound to the value of test
(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)))))