In this guide, we will discuss Clojure meta-with. This function is used to define a metadata map for any object.
Syntax
Following is the syntax.
(with-meta obj mapentry)
Parameters − ‘obj’ is the object with which metadata needs to be associated with. ‘mapentry’ is the metadata which needs to be associated with the object.
Return Value − Returns an object of the same type and value as obj, with mapentry as its metadata.
Example
An example on how this is used is shown in the following program.
(ns clojure.examples.example (:gen-class)) (defn Example [] (def my-map (with-meta [1 2 3] {:prop "values"})) (println (meta my-map))) (Example)
Output
The above program produces the following output.
{:prop values}
Next Topic : Click Here
Pingback: Clojure - Metadata | Adglob Infosystem Pvt Ltd