In the Clojure Koans :fin is being used in atoms.clj. Here is one example:
(def atomic-clock (atom 0))
"Atomic atoms are atomic"
(= 20 (do
(compare-and-set! atomic-clock 100 :fin)
@atomic-clock))
I understand that :fin is the new value. But why is it being used instead of number?
I've searched the documentation for :fin being used and cannot find its use other than in the Koans.
Thanks.
In Clojure, the colon makes something called a keyword, or a key:
user=> (type :xyz)
clojure.lang.Keyword
Keys are used in maps, because they're easy to check for equality and to convert to strings. You can see that, later in the same file, :fin
is used again in a check for equality:
(= :fin (do
(compare-and-set! __ __ __)
@atomic-clock)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With