开发者

How can I convert a keyword to a string? [duplicate]

开发者 https://www.devze.com 2023-02-19 02:09 出处:网络
This question already has answers here: How to convert a clojure keyword into a string? (5 answers) Closed 7 years ago.
This question already has answers here: How to convert a clojure keyword into a string? (5 answers) Closed 7 years ago.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消