some->>

macrosince v0.0-1798imported clojure.core/some->>Edit
(some->> expr & forms)

When expr is not nil, threads it into the first form (via ->>), and when that result is not nil, through the next, etc.


Details:

This is a safe navigation operator.


See Also:


Source docstring:
When expr is not nil, threads it into the first form (via ->>),
and when that result is not nil, through the next etc
Source code @ clojure:src/clj/clojure/core.clj
(defmacro some->>
  {:added "1.5"}
  [expr & forms]
  (let [g (gensym)
        steps (map (fn [step] `(if (nil? ~g) nil (->> ~g ~step)))
                   forms)]
    `(let [~g ~expr
           ~@(interleave (repeat g) (butlast steps))]
       ~(if (empty? steps)
          g
          (last steps)))))