Sorted maps sort their keys, but keywords and strings are not comparable:
(sorted-map "a" 1 :b 2) ClassCastException java.lang.String cannot be cast to clojure.lang.Keyword clojure.lang.Keyword.compareTo (Keyword.java:114) On Thursday, April 28, 2016 at 3:54:33 PM UTC-5, JPatrick Davenport wrote: > > Hello, > Please explain to me what's going on here. The first code snippet causes > the following error: "ClassCastException clojure.lang.Keyword cannot be > cast to java.lang.String java.lang.String.compareTo (String.java:111)" The > second code snippet doesn't. My understanding is that a *map* is a *map*. > > > First: > > > (let [s (apply sorted-map '(:a :b, :c {:d :e})) > c (assoc {} :payload s)] > (clojure.set/rename-keys (:payload c) {:a "a"})) > > > Second: > (let [s (apply hash-map '(:a :b, :c {:d :e})) > c (assoc {} :payload s)] > (clojure.set/rename-keys (:payload c) {:a "a"})) > > > Thanks, > > JPD > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.