How can I convert a keyword to a string? [duplicate]
In clojure, what is the idiomatic way to convert a keyword:
:some-keyword
to a string:
"some-keyword"
开发者_如何学编程
use name to do this:
user=> (name :some-keyword)
"some-keyword"
As Alex Ott mentionned, name is the best function for this, clojure.contrib also has a function you can call on any type: as-str which does this too:
(str :foo :bar) ;;=> ":foo:bar"
(as-str :foo :bar) ;;=> "foobar"
See http://clojure.github.com/clojure-contrib/string-api.html#clojure.contrib.string/as-str
精彩评论