On Wed, Dec 17, 2008 at 8:14 AM, Meikel Brandmeyer <m...@kotka.de> wrote: > > Hi, > > On 17 Dez., 14:55, MikeM <michael.messini...@invista.com> wrote: >> ((sorted-map 'a 1 'b 2) "a") => ClassCastException >> >> I would think that sorted-maps and hash-maps should both give nil for >> this, but perhaps the sorted-map implementation requires a cast? > > Obviously a string is not a symbol. A sorted-map only > makes sense with comparable keys. How do you compare > a string and a symbol for sorting? And indeed: > > ((sorted-map 'a 1 'b 2) 'c) => nil > > I think, that this is a bug - not in sorted-map, but in the user > code providing a wrong (type of) key.
I expected that ((sorted-map 'a 1 'b 2) "a") would return the same result as ((sorted-map 'a 1 'b 2) 'c) In both cases the key isn't in the map, so I thought nil would be returned. It appears that you can create a sorted-map where all the keys are symbols and you can create a sorted-map where all the keys are strings, but you can't create a sorted-map where some of the keys are symbols and some are strings. I take it this is because, as you say above, symbols and strings can't be compared to each other. -- R. Mark Volkmann Object Computing, Inc. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---