File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
library/src/scala/collection Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -1201,14 +1201,16 @@ final class StringOps(private val s: String) extends AnyVal {
1201
1201
def withFilter (p : Char => Boolean ): StringOps .WithFilter = new StringOps .WithFilter (p, s)
1202
1202
1203
1203
/** The rest of the string without its first char.
1204
- * @note $unicodeunaware
1205
- */
1206
- def tail : String = slice(1 , s.length)
1204
+ * @throws UnsupportedOperationException if the string is empty.
1205
+ * @note $unicodeunaware
1206
+ */
1207
+ def tail : String = if (s.isEmpty) throw new UnsupportedOperationException (" tail of empty String" ) else slice(1 , s.length)
1207
1208
1208
1209
/** The initial part of the string without its last char.
1209
- * @note $unicodeunaware
1210
- */
1211
- def init : String = slice(0 , s.length- 1 )
1210
+ * @throws UnsupportedOperationException if the string is empty.
1211
+ * @note $unicodeunaware
1212
+ */
1213
+ def init : String = if (s.isEmpty) throw new UnsupportedOperationException (" init of empty String" ) else slice(0 , s.length- 1 )
1212
1214
1213
1215
/** A string containing the first `n` chars of this string.
1214
1216
* @note $unicodeunaware
You can’t perform that action at this time.
0 commit comments