On Wednesday 17 December 2008 06:14, Meikel Brandmeyer 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.

What about when you use the three-argument form of (get ...) on a sorted 
map with a type mismatch on the supplied lookup key? One _might_ argue 
that in that case the exception should be caught and the default value 
returned.


> Sincerely
> Meikel


Randall Schulz

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to