• (== x)
  • (== x y)
  • (== x y & more)
Returns non-nil if nums all have the equivalent
value (type-independent), otherwise false

1 Example top

  • ;; true:
    (== 1)
    (== 1 1)       
    (== 1/1, 2/2, 3/3, 4/4)   
    (== 1, 1.0, 1/1)
    (== :foo)
    
    
    ;; false:
    (== 1 2)
    (== 1 \1)
    (== 1 "1")
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:1035 top

(defn ==
  "Returns non-nil if nums all have the equivalent
  value (type-independent), otherwise false"
  {:inline (fn [x y] `(. clojure.lang.Numbers (equiv ~x ~y)))
   :inline-arities #{2}
   :added "1.0"}
  ([x] true)
  ([x y] (. clojure.lang.Numbers (equiv x y)))
  ([x y & more]
   (if (== x y)
     (if (next more)
       (recur y (first more) (next more))
       (== y (first more)))
     false)))
Vars in clojure.core/==:
Used in 0 other vars

Comments top

2 comment(s) for ==.

So what is difference with =?

'== is defined only for numbers, where '= is general equality. The example showing (== :foo) as true is a bit misleading because (== :foo :foo) produces an exception. Unary == always returns true as an optimization.

Log in to add a comment.