Skip to content

Instantly share code, notes, and snippets.

Created September 20, 2015 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e8e658619f9b92f2bfca to your computer and use it in GitHub Desktop.
Save anonymous/e8e658619f9b92f2bfca to your computer and use it in GitHub Desktop.
(def a [1 2])
(apply conj a [3 4])
;; [1 2 3 4]
(def a (atom [1 2]))
(swap! a conj [3 4])
;; [1 2 [3 4]]
;; According to the docs, swap! Atomically swaps the value of atom to be:
;; (apply f current-value-of-atom args). Note that f may be called
;; multiple times, and thus should be free of side effects. Returns
;; the value that was swapped in.
;; So, why does a have a nested vector in it?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment