Search code examples
typesclojureboolean

what is the equivalent of boolean? in Clojure


Scheme supports boolean? to test whether a symbol or value is of boolean type.

(boolean? #\t)
(boolean? #\f)

While in Clojure, I can only found integer?, number?, list?, etc but without boolean?.

What is the equivalent of boolean? in Clojure?


Solution

  • you could do

    (defn boolean? [x]
      (instance? Boolean x))