macro | since v0.0-927 | clojure.core/doto | Edit |
(doto x & forms)
Evaluates x then calls all of the methods and functions with the value of x supplied at the front of the given arguments. The forms are evaluated in order. Returns x. (doto (new js/Map) (.set "a" 1) (.set "b" 2))
(core/defmacro doto
[x & forms]
(core/let [gx (gensym)]
`(let [~gx ~x]
~@(map (core/fn [f]
(if (seq? f)
`(~(first f) ~gx ~@(next f))
`(~f ~gx)))
forms)
~gx)))