Alias for the clojure.string Namespace
In Clojure, it's possible to alias a namespace in so many ways. You can read more at [clojure.org](https://www.clojure.org/guides/learn/namespaces). I'm used to seeing the alias for the namespace clojure.string
as str
. I haven't been coding much lately. Today, I was reminded that Clojure's str
function is spelled the same way! Aliasing doesn't prevent using the function str
:
(require '[clojure.string :as str])
(str 5)
;; => "5"
A teammate asked if we could use a different alias, like cs
or strs
. What's the advantage of using a different aliases than str
? Making it easier to grep for references to the str
function?
I was curious to see what's out there in the wild. Metabase seems to largely use the str
alias, as well as that clojure.org article mentioned above!
Subscribe to my newsletter
Read articles from Brett Rowberry directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Brett Rowberry
Brett Rowberry
I like programming (at work) and learning for fun. You'll often find me cooking and working on my house in my spare time.