File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
src/library/scala/collection/immutable Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -135,23 +135,29 @@ self =>
135135 def linesIterator : Iterator [String ] =
136136 linesWithSeparators map (line => new WrappedString (line).stripLineEnd)
137137
138- /** Returns this string with first character converted to upper case */
138+ /** Returns this string with first character converted to upper case.
139+ * If the first character of the string is capitalized, it is returned unchanged.
140+ */
139141 def capitalize : String =
140142 if (toString == null ) null
141143 else if (toString.length == 0 ) " "
144+ else if (toString.charAt(0 ).isUpper) toString
142145 else {
143146 val chars = toString.toCharArray
144147 chars(0 ) = chars(0 ).toUpper
145148 new String (chars)
146149 }
147150
148- /** Returns this string with the given `prefix` stripped. */
151+ /** Returns this string with the given `prefix` stripped. If this string does not
152+ * start with `prefix`, it is returned unchanged.
153+ */
149154 def stripPrefix (prefix : String ) =
150155 if (toString.startsWith(prefix)) toString.substring(prefix.length)
151156 else toString
152157
153158 /** Returns this string with the given `suffix` stripped. If this string does not
154- * end with `suffix`, it is returned unchanged. */
159+ * end with `suffix`, it is returned unchanged.
160+ */
155161 def stripSuffix (suffix : String ) =
156162 if (toString.endsWith(suffix)) toString.substring(0 , toString.length() - suffix.length)
157163 else toString
You can’t perform that action at this time.
0 commit comments