I've been working a bit with Clojure, and found their concept of truthy/falsy values quite refreshing for a dynamic language: Only false
and nil
are considered falsy values, everything else is truthy.
None of that confusion of "Is 0 true or false? What about the string "0"? What about empty strings and empty lists?".
Maybe this will bite me in the future, but so far it looks like a good decision.
On that note, I've also learned that Java's Boolean
actually provide (now deprecated) constructors that break reference equality (and in turn break Clojure's checks).
Namely new java.lang.Boolean("true") eq new java.lang.Boolean("true")
is false while the recommended alternative java.lang.Boolean.valueOf("true") eq java.lang.Boolean.valueOf("true")
is true.
I guess it makes some sense, but I always thought that there was no public Boolean
constructor.