If we have the following map:
(def m {:key 1 'sym 2 "str" 3})
The following are equivalent:
(:key m)
(m :key)
As are the following:
('sym m)
(m 'sym)
I think the commutativity of maps with symbols and keywords is a
valuable and good thing. I realize that the String class doesn't
implement the IFn interface, but it would be nice if maps and strings
were commutative. Unfortunately they aren't:
("str" m) ; throws invalid cast
(m "str") ; works fine
I realize that almost any type can be used as a key for a map, but
keywords, symbols, and strings are by far the most common, and it
would make sense to bring strings in line with the other two.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---