Skip to content

clojure.core/=

View this page on ClojureDocs

Type: function Added: Clojure 1.0 Examples: 7 Runnable: 4
([x] [x y] [x y & more])

Equality. Returns true if x equals y, false if not. Same as Java x.equals(y) except it also works for nil, and compares numbers and collections in a type-independent manner. Clojure's immutable data structures define equals() (and thus =) as a value, not an identity, comparison.

Examples

by citizen428 on
by phreed on . May have evaluation errors.
by phreed on . May have evaluation errors.
by huahaiy on
by huahaiy on
by mars0i on . May have evaluation errors.
by clojer on

Note by gstamp

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

Note by domokato

= compares collections in a type-independent manner but not numbers, despite what the docs say. See examples above.

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.