It's useful for example with -> macro when we eventually want to return its argument (in this case: state)
(defn example[state]
(-> state
update-function-1
update-function-2
identity))
It's useful for example with -> macro when we eventually want to return its argument (in this case: state)
(defn example[state]
(-> state
update-function-1
update-function-2
identity))
Comments top
3 comment(s) for identity.
I don't quite see the usefulness of this :P
It's useful for example with -> macro when we eventually want to return its argument (in this case: state)
(defn example[state]
(-> state update-function-1 update-function-2 identity))Here is another good example:
(some identity ((juxt :foo :bar) {:bar :b}))equivalent to
(let [map {:bar b}] (or (:foo map) (:bar map)))(some identity ((juxt :foo :bar) {:bar :b}))equivalent to(let [map {:bar b}] (or (:foo map) (:bar map)))