clojure.core/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.
Examples¶
Note by amirrajan¶
If you want to swap the entire atom, user reset!.
Note by KyleErhabor¶
When using swap!, it's important you're only taking into consideration the
value of the atom inside f. See https://ericnormand.me/mini-guide/atom-code-explanation for more information.
See also¶
Content from the matching ClojureDocs page, with authors credited on each contribution.