Skip to content

clojure.core/get

View this page on ClojureDocs

Type: function Added: Clojure 1.0 Examples: 10 Runnable: 8
([map key] [map key not-found])

Returns the value mapped to key, not-found or nil if key not present in associative collection, set, string, array, or ILookup instance.

Examples

by gstamp on
by mmwaikar on . May have evaluation errors.
by jafingerhut on
by rafmagana on
by cympfh on
by mars0i on
by reborg on
by puppe on . May have evaluation errors.
by timofeytt on
by usametov on

Note by Pierre-Thibault

Why is this character/string?

Note by hgijeon

(:mykey my-hash-map :none) means the same as (get my-hash-map :mykey :none) and
('mysym my-hash-map :none) means the same as (get my-hash-map 'mysym :none).
So, you can use (:a {:a 1 :b 2} :not-inserted) as (get {:a 1 :b 2} :a :not-inserted).
See http://clojure.org/data_structures#Data Structures-Keywords and http://clojure.org/data_structures#Data Structures-Symbols

Note by navigaid

(get get get get) is equivalent to get

as in:

((get get get get) {:a 1} :a)

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.