if-let

macrosince v0.0-927imported clojure.core/if-letEdit
(if-let bindings then)
(if-let bindings then else & oldform)

Details:

When test is logical true, evaluates then with the value of test bound to x. Otherwise, evaluates else with no bindings.

else defaults to nil.


See Also:


Source docstring:
bindings => binding-form test

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