Skip to content

Instantly share code, notes, and snippets.

@ddeaguiar
Created June 8, 2015 17:34
Show Gist options
  • Save ddeaguiar/8d5da1b7a8e8f6b6f78e to your computer and use it in GitHub Desktop.
Save ddeaguiar/8d5da1b7a8e8f6b6f78e to your computer and use it in GitHub Desktop.
swap! atom with update-in
(def my-state (atom {:foo {:bar [1 2 3]}}))
@my-state
;; {:foo {:bar [1 2 3]}}
(swap! my-state update-in [:foo :bar] #(conj % 4))
;; {:foo {:bar [1 2 3 4]}}
@my-state
;; {:foo {:bar [1 2 3 4]}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment