Converts first character of the string to upper-case, all other
characters to lower-case.
user=> (require 'clojure.string) nil user=> (clojure.string/capitalize "MiXeD cAsE") "Mixed case" user=> (clojure.string/capitalize "mIxEd CaSe") "Mixed case"
(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))))))
Comments top
No comments for capitalize. Log in to add a comment.