-
-
Save rockBreaker/82c2c15be7a871e17ee3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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