title: Maps and records equality in Clojure
body: <p>I found the behavior of Clojure confusing regarding equality between maps and records. In this first example, we have two different types which are structurally equal. The equality = function returns true:</p>
  
  <pre><code>user&gt; (defn make-one-map
           []
         {:a "a" :b "b"})
  #'user/make-one-map
  user&gt; (def m1 (make-one-map))
  #'user/m1
  user&gt; m1
  {:a "a", :b "b"}
  user&gt; (def m2 {:a "a" :b "b"})
  #'user/m2
  user&gt; m2
  {:a "a", :b "b"}
  user&gt; (= m1 m2)
  true
  user&gt; (type m1)
  clojure.lang.PersistentArrayMap
  user&gt; (type m2)
  clojure.lang.PersistentHashMap
  </code></pre>
  
  <p>In the second example we have a hashmap and a record which are structurally equivalent but the = function returns false:</p>
  
  <pre><code>user&gt; (defrecord Titi [a b])
  user.Titi
  user&gt; (def titi (Titi. 1 2))
  #'user/titi
  user&gt; titi
  #user.Titi{:a 1, :b 2}
  user&gt; (= titi {:a 1 :b 2})
  false
  </code></pre>
  
  <p>Why are the differences? I'm using Clojure 1.3 and I found them really confusing.</p>