Having both options available also allows you to make NullPointerException-averse decisions as appropriate.
That is, in this function: (defn foo [a-map] (a-map :foo)) I'm potentially exposed to an NPE if the given map is nil. By rewriting it: (defn foo [a-map] (:foo a-map)) I avoid this possibility, and the function returns nil even when a-map is nil. The reverse is also frequently useful. On Thursday, December 20, 2012 6:13:23 PM UTC-5, Jonathon McKitrick wrote: > > I thought it was pretty interesting to treat maps as functions, and even > more intrigued at treating keywords as functions as well. > > What does this gain from a language design perspective, that you cannot > get with (get map keyword) or ever (map keyword)? Why the additional > option of (keyword map) ? > -- 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