1.3.0 permalink Arrow_down_16x16

boolean

clojure.core

  • (boolean x)
Coerce to boolean

1 Example top

  • ;; Everything except `false' and `nil' is true in boolean context.
    user=> (into {} (map #(vector % (boolean %)) [true false nil [] {} '() #{} ""]))
    {true true, false false, nil false, [] true, {} true, #{} true, "" true}
    
    user=> (clojure.pprint/pp)
    {true true,
     false false,
     nil false,
     [] true,
     {} true,
     #{} true,
     "" true}
    nil
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:3102 top

(defn boolean
  "Coerce to boolean"
  {
   :inline (fn  [x] `(. clojure.lang.RT (booleanCast ~x)))
   :added "1.0"}
  [x] (clojure.lang.RT/booleanCast x))
Vars in clojure.core/boolean:
Used in 0 other vars

Comments top

No comments for boolean. Log in to add a comment.