ClojureDocs

Nav

Namespaces

some->

clojure.core

Available since 1.5 (source)
  • (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
2 Examples
user=> (-> {:a 1} :b inc)
;; NullPointerException   clojure.lang.Numbers.ops (Numbers.java:942)

user=> (some-> {:a 1} :b inc)
;; nil
;; Often used to "short-circuit out" of a series of steps:

(some-> val
        step1
        step2
        step3)

;; When nil is returned by any step, the further steps are not executed. Thus
;; the nil case need be handled only once, at the end.
See Also

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

Added by jw-00000

Threads the expr through the forms. Inserts x as the second item in the first form, making a list ...

Added by jw-00000

Takes an expression and a set of test/form pairs. Threads expr (via ->) through each form for whic...

Added by abrooks

Takes an expression and a set of test/form pairs. Threads expr (via ->>) through each form for whi...

Added by abrooks

Binds name to expr, evaluates the first form in the lexical context of that binding, then binds na...

Added by abrooks

Threads the expr through the forms. Inserts x as the last item in the first form, making a list of...

Added by abrooks
0 Notes
No notes for some->