==
is for comparing numbers. If either of its arguments is not a number, it will always return false:
(== :a :a)
; => false
As you can see by saying (clojure.contrib.repl-utils/source ==)
at the REPL (with repl-utils
require
'd, of course), ==
calls the equiv
method of clojure.lang.Numbers
. The relevant bit of clojure/lang/Numbers.java
(from the latest or close-to-latest commit on GitHub):
static public boolean equiv(Object x, Object y){
return y instanceof Number && x instanceof Number
&& equiv((Number) x, (Number) y);
}
Use =
for equality comparisons of things which may not be numbers. When you are in fact dealing with numbers, ==
ought to be somewhat faster.