Question

Adding meta data to an object returns a new object with the metadata attached:

(def plain-data [1 2 3])
(def decorated-data (with-meta plain-data {:url "http://stackoverflow.com"}))

;; returns false
(identical? plain-data decorated-data)

How do I recover the original plain-data from the decorated-data?

I'd like to do something like,

(def undecorated-data (with-meta decorated-data nil))

;; how can I make this return true?
(identical? plain-data undecorated-data)
Was it helpful?

Solution

Adding metadata doesn't wrap the value, it returns a clone of the value with metadata attached - there's no way to recover the original thing. However it's not clear why you would ever need to do that, use = if you need to check for equality.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top