(= 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.
user=> (= 1)
true
user=> (= 1 1)
true
user=> (= 1 2)
false
user=> (= 1 1 1)
true
user=> (= 1 1 2)
false
user=> (= '(1 2) [1 2])
true
user=> (= nil nil)
true
user=> (= (sorted-set 2 1) (sorted-set 1 2))
true
;; It should be noted that equality is not defined for Java arrays.
;; Instead you can convert them into sequences and compare them that way.
;; (= (seq array1) (seq array2))
;; There are functional differences between = and ==
;; = may introduce java autoboxing
;; true:
(= 1)
(= 1 1)
(= 1/1, 2/2, 3/3, 4/4)
(= :foo)
(= nil anything) ; anything = nil
;; false:
(= 1, 1.0, 1/1) ; differs from ==
(= 1 2)
(= 1 \\1) ; differs from ==
(= 1 "1") ; differs from ==
;; If passed a single value (= x) the result is always true.
(= 1)
(= nil)
(= false)
(= true)
(= {:a 1 :b2})
(= 'false)
;;=> true