I have created mutable state map using an atom. I would like to get the value of the key from the map. I have tried it in the below way, But it returns "nil" value
(def coll1 (atom {}) )
(swap! coll1 assoc :a "XXXX" :b "XXXXXX")
This statement printing
(println coll1)
#object[clojure.lang.Atom 0x771a660 {:status :ready, :val {:a XXXX, :b XXXXXX}}]
I have written this statement to fetch value of :a
(println (get-in coll1 [:val :a]))
You need to dereference the atom. This link will help. For your case, you are looking for something like (get @coll1 :a)
or (:a @coll1)
or (@coll1 :a)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.