In this guide, we will discuss Clojure Maps get. Returns the value mapped to key, not-found or nil if key is not present.
Syntax
Following is the syntax.
(get hmap key)
Parameters − ‘hmap’ is the map of hash keys and values. ‘key’ is the key for which the value needs to be returned.
Return Value − Returns the value of the key passed to the get function.
Example
Following is an example of get in Clojure.
(ns clojure.examples.example (:gen-class)) (defn example [] (def demokeys (hash-map "z" "1" "b" "2" "a" "3")) (println demokeys) (println (get demokeys "b"))) (example)
Output
The above code produces the following output.
{z 1, b 2, a 3} 2
Next Topic : Click Here
Pingback: Clojure - Maps | Adglob Infosystem Pvt Ltd