Created
June 8, 2015 17:34
-
-
Save ddeaguiar/8d5da1b7a8e8f6b6f78e to your computer and use it in GitHub Desktop.
swap! atom with update-in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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