Using swap for MERGE (add to) a nested map in a Clojure atom?

Let's say I have an atom containing such a map:

{:count 0 :map hash-map} 

How can I use swap to merge another key-value pair into :map ?

+6
clojure
source share
1 answer

You would use assoc-in :

 (swap! my-atom assoc-in [:map :new-key] value) 
+9
source share

All Articles