1.3.0 permalink Arrow_down_16x16

capitalize

clojure.string

  • (capitalize s)
Converts first character of the string to upper-case, all other
characters to lower-case.

1 Example top

  • user=> (require 'clojure.string)
    nil
    
    user=> (clojure.string/capitalize "MiXeD cAsE")
    "Mixed case"
    
    user=> (clojure.string/capitalize "mIxEd CaSe")
    "Mixed case"
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/string.clj:146 top

(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))))))
Vars in clojure.string/capitalize:
Used in 0 other vars

Comments top

No comments for capitalize. Log in to add a comment.