What might confuse you, is why Clojure even have true? and false? functions?

Its because conditional constructs like if, cond, when, test for truthy (aka 
logical true) and falsey (aka logical false), not true and false. Nil and False 
are falsey, and everything else is truthy.

Most of the time this is great, you can do:

(if (:a {}) ... ...)

Since if tests for truthy, keyword access of map values can be used as a valid 
if condition.

But sometimes that's not what you want, sometimes you want nil to not be 
considered false, or :error to not be considered true. In those cases, you wrap 
the test condition in true? and false?. That way you're explicitly checking for 
true or false, not truthy and falsey.

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to