(clj 3) Clojure’s ‘and’ and ‘or’ are weird (but not really)
Early in chapter 3 of the Brave and True-book the Boolean operators
or are introduced:
Clojure uses the Boolean operators
orreturns either the first truthy value or the last value.
andreturns the first falsey value or, if no values are falsey, the last truthy value.
This explanation is followed by some examples:
(or false nil :large_I_mean_venti :why_cant_I_just_say_large) ; => :large_I_mean_venti (or (= 0 1) (= "yes" "no")) ; => false (or nil) ; => nil
(and :free_wifi :hot_coffee) ; => :hot_coffee (and :feelin_super_cool nil false) ; => nil
What I found remarkable about this is that
or do not return a boolean in all cases. Before I go into that, let’s back up a second and cover their basics in a little more depth first.