(when-let bindings & body)
bindings => binding-form test
When test is true, evaluates body with binding-form bound to the value of test
Spec
(clojure.spec.alpha/fspec
:args
(clojure.spec.alpha/cat
:bindings
(clojure.spec.alpha/and
clojure.core/vector?
:clojure.core.specs.alpha/binding)
:body
(clojure.spec.alpha/* clojure.core/any?))
:ret
clojure.core/any?
:fn
nil)
Source
(defmacro when-let
"bindings => binding-form test
When test is true, evaluates body with binding-form bound to the value of test"
{: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)))))