function | since v0.0-927 | clojure.core/get | Edit |
(get o k)
(get o k not-found)
Returns the value mapped to key k
.
Returns not-found
or nil if k
is not present in o
.
Returns the value mapped to key, not-found or nil if key not present in associative collection, set, string, array, or ILookup instance.
(defn get
([o k]
(when-not (nil? o)
(cond
(implements? ILookup o)
(-lookup o k)
(array? o)
(when (and (some? k) (< k (.-length o)))
(aget o (int k)))
(string? o)
(when (and (some? k) (< -1 k (.-length o)))
(.charAt o (int k)))
(native-satisfies? ILookup o)
(-lookup o k)
:else nil)))
([o k not-found]
(if-not (nil? o)
(cond
(implements? ILookup o)
(-lookup o k not-found)
(array? o)
(if (and (some? k) (< -1 k (.-length o)))
(aget o (int k))
not-found)
(string? o)
(if (and (some? k) (< -1 k (.-length o)))
(.charAt o (int k))
not-found)
(native-satisfies? ILookup o)
(-lookup o k not-found)
:else not-found)
not-found)))