store/[org.clojure/clojure "1.8.0"] clj::clojure.core/if-some

Official Documentation

Add notes
Arities
==================================================
   [bindings then]
   [bindings then else & oldform]

Docstring
==================================================
  bindings => binding-form test

   If test is not nil, evaluates then with binding-form bound to the
   value of test, if not, yields else

Source

(defmacro if-some
  "bindings => binding-form test

   If test is not nil, evaluates then with binding-form bound to the
   value of test, if not, yields else"
  {:added "1.6"}
  ([bindings then]
   `(if-some ~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 (nil? temp#)
          ~else
          (let [~form temp#]
            ~then))))))

Uses on crossclj