If I have a symbol who's namespace is an alias, like q/w, how can I find its actual namespace, say actual.namespace/w ?
I know that resolve
will give me the fully qualified var, but I don't know how to get the namespace of a var.
The best I can do is:
(defn fqns [s] (str (get (ns-aliases *ns*) (symbol (namespace s)))))
surely there's a simpler way ?
You can get the namespace object of a symbol as shown below (if you want name of ns as string then just call str at the end):
(defn fqns [s] (->> (resolve s) meta :ns))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With