You're viewing version 1.2.0 of ==. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16
  • (== x)
  • (== x y)
  • (== x y & more)
Returns non-nil if nums all have the same value, 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:898 top

(defn ==
  "Returns non-nil if nums all have the same value, 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/==: defn first next
Used in 1 other vars deferror

Comments top

1 comment(s) for ==.

There is a difference between "=" and "==". For primitives you definitely want to use "==" as "=" will result in a cast to the wrapped types for it's arguments.

This may not be the case come Clojure 1.3 (see [1])

[1] http://github.com/clojure/clojure/commit/df8c65a286e90e93972bb69392bc106128427dde

Log in to add a comment.