dissoc removes one or more specified keys from an associative collection and returns the resulting collection. It is commonly used with maps alongside assoc and assoc-in. section 11.3.1
Its contract is small but flexible:
- The collection argument is mandatory, associative, and defaults to an empty map when nil. section 11.3.1
- The key and any additional keys are optional; each key is matched using equality comparison. section 11.3.1
- Vectors are associative data structures too, but dissoc keys must be integers when operating on them. section 11.3.1
Remove several map entries
(def m {:a "1" :b "2" :c "3"}) (dissoc m :a :c) ;; {:b 2}
Use dissoc in a pipeline
(-> {nil 0 :c 2} (assoc :a 1) (dissoc nil) (update :c inc) (merge {:b 2})) ;; {:c 3, :a 1, :b 2}
