function/macro | since v0.0-927 | clojure.core/== | Edit |
(== x)
(== x y)
(== x y & more)
This is an equality check for numbers of different types that was carried over from Clojure, to allow compatibility when converting code to ClojureScript.
Since there is only a single number type in JavaScript, 64-bit floating point, there is no
reason to use the ==
operator in ClojureScript.
Behavior on non-number arguments is undefined.
(== 1 1)
;;=> true
(== 1 2)
;;=> false
Returns non-nil if nums all have the equivalent value, otherwise false. Behavior on non nums is undefined.
(defn ^boolean ==
([x] true)
([x y] (-equiv x y))
([x y & more]
(if (== x y)
(if (next more)
(recur y (first more) (next more))
(== y (first more)))
false)))
(core/defmacro ^::ana/numeric ==
([x] true)
([x y] (bool-expr (core/list 'js* "(~{} === ~{})" x y)))
([x y & more] `(and (== ~x ~y) (== ~y ~@more))))