function | since v0.0-927 | clojure.core/name | Edit |
(name x)
Returns the name string of a possibly namespace-qualified keyword or symbol.
Equivalent to identity
for strings.
With namespaces:
(name :foo/bar)
;;=> "bar"
(name 'foo/bar)
;;=> "bar"
Without namespaces:
(name :foo)
;;=> "foo"
(name 'foo)
;;=> "foo"
Strings have no concept of a namespace:
(name "foo/bar")
;;=> "foo/bar"
(name "foo")
;;=> "foo"
Returns the name String of a string, symbol or keyword.
(defn name
[x]
(if (implements? INamed x)
(-name x)
(if (string? x)
x
(throw (js/Error. (str "Doesn't support name: " x))))))