I’m trying to wrap my head around how Clojure works. This is something I’ve ran into that I’d like to get a solid understanding of.
If I have code like this,
(let [obj (atom {:foo "F" :bar "B"})]
(
; How to set obj.foo to "O"?
))
What’s the syntax to change obj.foo to “O” instead of “F”? All the examples I’ve found have been for updating primitives and not for updating a nested value.
Ok, that makes sense. I’ll try to get myself to stop calling them objects. The main reason I’ve been falling back to that is map is also a function so it’s been a bit confusing to keep track of whether map is talking about a map data structure or the map function. I have a similar issue with the thread macro since it’s not at all related with what thread usually means in programs. Part of the learning process.
Yep, definitely. I think what was tripping me up was thinking of the entire map as the atom instead of the atom being, in essence, a pointer to a map and then changing the pointer to point to a new map.