Clojure – Maps dissoc

Clojure maps dissoc

In this guide, we will discuss Clojure Maps dissoc. Dissociates a key value entry from the map.

Syntax

Following is the syntax.

(dissoc hmap key)

Parameters − ‘hmap’ is the map of hash keys and values. ‘key’ is the key which needs to be dissociated from the HashMap.

Return Value − Returns a map with the dissociated key.

Example

Following is an example of dissoc in Clojure.

(ns clojure.examples.example
   (:gen-class))
(defn example []
   (def demokeys (hash-map "z" "1" "b" "2" "a" "3"))
   (println (dissoc demokeys "b")))
(example)

Output

The above code produces the following output.

{z 1, a 3}

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply