A map is a collection that assigns keys to values. The get
method is used to get the element of a collection by its key.
(get hmap key)
The get method receives two parameters:
hmap
: The hash key and valuekey
: The keys used to get the valueThis method returns the value of the key passed.
(ns clojure.examples.example(:gen-class))(defn gett [](def keyss (hash-map "z" "1" "b" "22" "f" "53"))(println keyss)(println (get keyss "z")))(gett)
gett
function.keyss
, using the def
keyword. Next, we give it the collection.(hashmap "z" "1" "b" "22" "f" "53")
.println
. The get
method is used to get the data value using key.println
to print the value returned by the key z
.gett
function.