Hi Renata,

> How can I update the atom accounts in the field of operations?
> 
> (def accounts (atom [{:id "7512a15b-0770-4a9b-a74b-389374b46461", :balance 
> 0.0, :operations nil, :blocked false} 
>   {:id "7446cfe6-882c-4f25-bad1-5ed8c9aea994", :balance 0.0, :operations nil, 
> :blocked false} 
>   {:id "3136860d-ab7f-4814-8f3b-2d18048db9b9", :balance 0.0, :operations nil, 
> :blocked false} 
>   {:id "2dc20615-f1f7-4637-9602-ae9494689166", :balance 0.0, :operations nil, 
> :blocked false}
>   {:id "c6dccf4a-535c-4eba-8cfc-0554408de8bd", :balance 0.0, :operations nil, 
> :blocked false}]))
> 
> I tried this:
> 
> (swap! accounts (fn [x] (update-in x [:operations]  #(if (= (:id %) 
> account-id) new-value))))
> 
> and returns "key must be integer" because of [:operations]

the atom hold and array of accounts. In swap! you are trying to access one (!) 
value in a key-path [:operations] but access to elements of an array is not 
valid via a key-path but by using indexes.

What you are seemingly trying to do is to map over the contents of the array in 
the atom which is not what you coded here.

- Axel

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to