-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
The Clojure Workshop
By :
Up until now, we have been using conditional expressions intuitively, possibly on the basis of how they usually work with other programming languages. In this final section, we will review and explain Boolean expressions and the related comparison functions in detail, starting with nil and truthiness in Clojure.
nil is a value that represents the absence of value. It is also often called NULL in other programming languages. Representing the absence of value is useful because it means that something is missing.
In Clojure, nil is "falsey," which means that nil behaves like false when evaluated in a Boolean expression.
false and nil are the only values that are treated as falsey in Clojure; everything else is truthy. This simple rule is a blessing (especially if you are coming from a language such as JavaScript) and makes our code more readable and less error-prone. Perhaps it's just that Clojure was not out yet when Oscar Wilde wrote...