Skip to content

Instantly share code, notes, and snippets.

@jjconti
Created June 25, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jjconti/054e15b5a9a07ecadf33 to your computer and use it in GitHub Desktop.
Save jjconti/054e15b5a9a07ecadf33 to your computer and use it in GitHub Desktop.
Clojure: access a map using a key as a function or the map as a function
user=> (def d {:a 1 :b 2 :c 3})
#'user/d
user=> (:b d)
2
user=> (d :b)
2
@jjconti
Copy link
Author

jjconti commented Jun 25, 2015

Note: key has to be a keyword. If the key is, for example, and Integer. It can't be used as a function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment