Specific wording in exception message for String methods.

This commit is contained in:
Ilya Gorbunov
2015-06-04 16:45:55 +03:00
parent a1d8e9d633
commit 009baa11fc
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -292,7 +292,7 @@ public fun <T> List<T>.dropLast(n: Int): List<T> {
* Returns a string with the last [n] characters removed.
*/
public fun String.dropLast(n: Int): String {
require(n >= 0, { "Requested element count $n is less than zero." })
require(n >= 0, { "Requested character count $n is less than zero." })
return take((length() - n).coerceAtLeast(0))
}
@@ -1384,7 +1384,7 @@ public fun <T> Stream<T>.take(n: Int): Stream<T> {
* Returns a string containing the first [n] characters from this string, or the entire string if this string is shorter.
*/
public fun String.take(n: Int): String {
require(n >= 0, { "Requested element count $n is less than zero." })
require(n >= 0, { "Requested character count $n is less than zero." })
return substring(0, Math.min(n, length()))
}
@@ -1532,7 +1532,7 @@ public fun <T> List<T>.takeLast(n: Int): List<T> {
* Returns a string containing the last [n] characters from this string, or the entire string if this string is shorter.
*/
public fun String.takeLast(n: Int): String {
require(n >= 0, { "Requested element count $n is less than zero." })
require(n >= 0, { "Requested character count $n is less than zero." })
val length = length()
return substring(length - Math.min(n, length), length)
}