Skip to content

Instantly share code, notes, and snippets.

@mnylen mnylen/gist:2870176
Created Jun 4, 2012

Embed
What would you like to do?
(def x (transient {}))
(conj! x [\A 1]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\B 2]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\C 3]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\D 4]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\E 5]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\F 6]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\G 7]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\H 8]) ;; => #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@646dee9f>
(conj! x [\I 9]) ;; => #<TransientHashMap clojure.lang.PersistentHashMap$TransientHashMap@77aa13c5>
(conj! x [\J 10]) ;; => #<TransientHashMap clojure.lang.PersistentHashMap$TransientHashMap@34f5b235>
(persistent! x) ;; => {\A 1, \B 2, \C 3, \D 4, \E 5, \F 6, \G 7, \H 8}
;; Note how the \I and \J keys are missing from the resulting map
;; Also, note that the result from (conj! x [\I 9]) is a different transient map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.