dissoc!

clojure.core

  • (dissoc! map key)
  • (dissoc! map key & ks)
Alpha - subject to change.
Returns a transient map that doesn't contain a mapping for key(s).

1 Example top

  • ;; dissoc! works on a transient map
    
    ;; WARNING: Below is an example of what is called "bashing in place" of
    ;; a transient, and is _NOT_ the correct way to use transients.  See assoc!
    ;; examples for some discussion of the reason.
    
    (let [my-map (transient {:x 1 :y 2 :z 3})]
      (dissoc! my-map :x)   ; mistake is to use my-map below, not dissoc! return val
      (persistent! my-map)) ; returns persistent map {:y 2 :z 3}
    
    
    ;; Here is a correct way to do the operation described above:
    
    (let [my-map (transient {:x 1 :y 2 :z 3})
          x (dissoc! my-map :x)]    ; after this, don't use my-map again, only x
      (persistent! x))    ; returns persistent map {:y 2 :z 3}
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:2964 top

(defn dissoc!
  "Alpha - subject to change.
  Returns a transient map that doesn't contain a mapping for key(s)."
  {:added "1.1"
   :static true}
  ([^clojure.lang.ITransientMap map key] (.without map key))
  ([^clojure.lang.ITransientMap map key & ks]
   (let [ret (.without map key)]
     (if ks
       (recur ret (first ks) (next ks))
       ret))))
Vars in clojure.core/dissoc!:
Used in 0 other vars

Comments top

No comments for dissoc!. Log in to add a comment.