A map is a collection that assigns keys to values.
A contains method is used to search for a key in a collection. It is used to check if a key exists in a collection.
(contains hmap key)
The get method receives two parameters:
hmap: The hash key and value.key: Keys being searched.The contains method returns a boolean type. It returns true if the key is found and false if it is not found.
Let's look at the code below:
(ns clojure.examples.example(:gen-class))(defn contains_s [](def keys_s (hash-map "z" "1" "b" "22" "f" "53"))(println (contains? keys_s "z"))(println (contains? keys_s "x")))(contains_s)
In the code above:
contains_s function.keys_s using the def keyword then we give it the collection(hashmap "z" "1" "b" "22" "f" "53").println to print the value returned by the key z using the contains_s method. So we get true because the key z is present in the collection.println to print the value returned by the key z using the contains_s method. So we get false because the key x is not present in the collection.contains_s function.