find searches an associative collection for a key and returns a key-value entry when the key is present, or nil otherwise. It accepts Clojure maps, Java Map implementations, records, vectors, subvectors, and native vectors. The returned entry is a java.util.Map$Entry; use key and val to extract its components. section 11.2.2
Listing 11.7. → Searching, Key-value pair
(find [map key]) (key [e]) (val [e])
Use the compact signatures to compare find with key and val: find locates an entry, while the other functions extract its key or value. section 11.2.2
Map lookup returns an entry
(find {:a 1 :b 2} :b) ;; [:b 2] (type (find {:a 1 :b 2} :b)) ;; clojure.lang.MapEntry (key (find {:a 1 :b 2} :b)) ;; :b
Vector lookup uses an index
(find [:a :b :c] 1) ;; [1 :b] (find [:a :b :c] :c) ;; nil (find (subvec [:x :a :b :c] 1 3) 1) ;; [1 :b]
Choose find when the entry itself matters, especially when processing several maps:
- Use get when you want only the value, an optional not-found value, or flexible access across supported collection types. section 8.2.2
- Treat non-index vector keys cautiously; unusual numeric keys can produce unpredictable results rather than a meaningful lookup. section 11.2.2


