str-named
is a Clojure function used to stringify values,
some of which may implement clojure.lang.Named
, such as keywords.
I found the need to constantly rewrite this function, or a variant of this function, with every new Clojure project.
I finally decided to move str-named
into a library instead.
It seems that some other Clojure projects
similarly define such a function.
Add the following dependency to your project.clj
file:
[str-named "1.0.0"]
str-named
can be used as you would clojure.core/str
:
(ns project.core
(:require
[str-named.core :refer [str-named]]))
(str-named 10 \- :keyword)
;=> "10-keyword"
Any arguments to str-named
which implement clojure.lang.Named
, such as keywords, will
have (name value)
used to produce the string representation of the value instead of (str value)
.
All other values will have their string representation produced by calling (str value)
as with
clojure.core/str
.
Copyright © 2013 Chris LaVoie
Distributed under the Eclipse Public License, the same as Clojure.