How can I add meta-data to a closure vector?
I wish to add type data to a clojure vector by adding meta d开发者_开发技巧ata. What do I need to add to this to achieve this:
(def r (ref [1 2 3]))
Note that I want to add the meta data to [1 2 3]. Is this even the right way of doing this? I mean, should I be adding meta-data to the vector [1 2 3] to "r"?
I think it should be added to 'r':
user=> (def r (ref [1 2 3] :meta {:type "vector"}))
#'user/r
user=> (meta r)
{:type "vector"}
精彩评论