Skip to content

Instantly share code, notes, and snippets.

@rockBreaker
Created January 11, 2016 16:56
Show Gist options
  • Save rockBreaker/82c2c15be7a871e17ee3 to your computer and use it in GitHub Desktop.
Save rockBreaker/82c2c15be7a871e17ee3 to your computer and use it in GitHub Desktop.
(defn ^String capitalize
"Converts first character of the string to upper-case, all other
characters to lower-case."
{:added "1.2"}
[^CharSequence s]
(let [s (.toString s)]
(if (< (count s) 2)
(.toUpperCase s)
(str (.toUpperCase (subs s 0 1))
(.toLowerCase (subs s 1))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment