macro | since v0.0-2261 | imported clojure.core/when-some | Edit |
(when-some bindings & body)
When test
is not nil, evaluates body
with x
bound to the value of test
.
bindings => binding-form test When test is not nil, evaluates body with binding-form bound to the value of test
(defmacro when-some
{:added "1.6"}
[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]
(if (nil? temp#)
nil
(let [~form temp#]
~@body)))))