Right. Let's make this clear: outside of the Java interoperability stuff, you cannot change the value of a variable in Clojure. Ever. All the data types are immutable; you can only build new values on top of existing ones, not modify the old ones.
When you conj something onto a vector, it doesn't change that vector; it returns a new vector. The new vector reuses the old one's memory for efficiency, but if you look at the old one it doesn't have the new member. It's unchanged. What can change are references. So you can make a reference to the vector, and then build a new vector with the new items, and then change the reference to point to the new vector. That's what (swap!) does. But you have to have a reference to start with. Which (atom) gives you. But a reference is not the same as a vector; you can't use it directly when you need a vector, but must dereference it with @. Example: Clojure 1.1.0 user=> (def start-colors [:black :white]) #'user/start-colors user=> (def saved-colors (atom start-colors)) #'user/saved-colors user=> start-colors [:black :white] user=> @saved-colors [:black :white] user=> (swap! saved-colors conj :red) [:black :white :red] user=> start-colors [:black :white] user=> saved-colors #<a...@1d256fa: [:black :white :red]> user=> @saved-colors [:black :white :red] user=> -- Mark J. Reed <markjr...@gmail.com> -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.