Parses a symbol name into a namespace and a name. If name doesn't
contain a namespace, the default-ns is used (nil if none provided).
(defn symbol-name-parts
"Parses a symbol name into a namespace and a name. If name doesn't
contain a namespace, the default-ns is used (nil if none provided)."
([symbol]
(symbol-name-parts symbol nil))
([#^String symbol default-ns]
(let [ns-pos (.indexOf symbol (int \/))]
(if (= ns-pos -1) ;; namespace found?
[default-ns symbol]
[(.substring symbol 0 ns-pos) (.substring symbol (inc ns-pos))]))))
Comments top
No comments for symbol-name-parts. Log in to add a comment.