get-in

functionsince v0.0-927 clojure.core/get-inEdit
(get-in m ks)
(get-in m ks not-found)

Details:

Returns the value in a nested associative structure, where ks is a sequence of keys.

Returns nil if the key is not found, or not-found if supplied.


See Also:


Source docstring:
Returns the value in a nested associative structure,
where ks is a sequence of keys. Returns nil if the key is not present,
or the not-found value if supplied.
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn get-in
  {:added "1.2"
   :static true}
  ([m ks]
   (loop [m m
          ks (seq ks)]
     (if (nil? ks)
       m
       (recur (get m (first ks))
         (next ks)))))
  ([m ks not-found]
     (loop [sentinel lookup-sentinel
            m m
            ks (seq ks)]
       (if-not (nil? ks)
         (let [m (get m (first ks) sentinel)]
           (if (identical? sentinel m)
             not-found
             (recur sentinel m (next ks))))
         m))))