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
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.
There's also (sorted-map-by ...):
user=> (doc sorted-map-by)
-------------------------
clojure.core/sorted-map-by
([comparator & keyvals])
keyval => key val
Returns a new sorted map with supplied mappings,
using the supplied comparator.
So you can write a less stringent comparator if you like and use that to
side-step this sort of exception.
Randall Schulz