In my application I need to convert clojure keyword eg. :var_name into a string "var_name". Any ideas how that could be done?
+14
A:
user=> (doc name)
-------------------------
clojure.core/name
([x])
Returns the name String of a string, symbol or keyword.
nil
user=> (name :var_name)
"var_name"
kotarak
2010-09-15 15:49:06
I cannot imagine a more complete answer, but just for fun I shall dare someone to come up with it.
Hamish Grubijan
2010-09-15 15:55:57
@Hamish Perhaps by adding `(source name)`?
ponzao
2010-09-15 18:05:47
How `name` works should not be of interest. The docstring is the contract. Anything else is an implementation detail, one should not rely upon.
kotarak
2010-09-15 19:32:37
Thanks! My initial reaction was to do this: (.replaceFirst (.toString (keyword "abc")) ":" "")
Bart J
2010-09-16 06:26:55
Thanks kotarak! I am loving this Clojure more every day! This is my third day.
Santosh
2010-09-16 08:46:47
@BartJ: `(doc subs)` => `(subs (str (keyword "abc")) 1)` ;)
kotarak
2010-09-16 10:01:41
@user448587: You are welcome. :)
kotarak
2010-09-16 10:02:35
@kotarak: I guess that shows my Java inclination ;)
Bart J
2010-09-16 11:09:01