May 2018
Beginner to intermediate
290 pages
6h 43m
English
Programmers new to Clojure sometimes get lost in expressions like this:
| | (def title-atom (atom "Pride and Prejudice")) |
The thing to keep in mind is that this expression creates two value containers. The first is a var, which gets bound to the name title-atom. The value of that var is another container, an atom. And inside the atom we find the string "Pride and Prejudice".
If we swap! another value in, perhaps like this, the var doesn’t change at all:
| | (swap! title-atom #(str % " and Zombies")) |
It is still the same var, bound to the same name and pointing at the same atom. It’s the value inside the atom that gains some zombies.
Another thing to keep in mind is what happens should an update function fail. The good ...
Read now
Unlock full access