alter-meta!

functionsince v0.0-927 clojure.core/alter-meta!Edit
(alter-meta! iref f & args)

(alter-meta! data f & args)

Alter the metadata of data to be (apply f its-current-meta args).


Details:

Metadata of vars cannot be altered since they are statically determined at compile-time.


Examples:

Metadata of symbols and collections can be altered:

(def a ^:foo [1 2 3])
(meta a)
;;=> {:foo true}

(alter-meta! a assoc :bar true)
(meta a)
;;=> {:foo true, :bar true}

Metadata of vars cannot be altered:

(def a [1 2 3])
(meta #'a)
;;=> {:arglists (), :test nil, :name a, :column 1, :line 1, :file "", :doc nil, :ns cljs.user}

(alter-meta! #'a assoc :bar true)
(:bar (meta #'a))
;;=> nil

See Also:


Source docstring:
Atomically sets the metadata for a namespace/var/ref/agent/atom to be:

(apply f its-current-meta args)

f must be free of side-effects
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn alter-meta!
  [iref f & args]
  (set! (.-meta iref) (apply f (.-meta iref) args)))