String.split(Pattern, limit) now treats limit differently: 0 means no limit is specified, but trailing empty elements are not stripped; -1 and other negative values are not allowed.
This commit is contained in:
@@ -120,8 +120,14 @@ public fun String.format(locale: Locale, vararg args : Any?) : String = java.lan
|
||||
|
||||
/**
|
||||
* Splits this string around matches of the given regular expression.
|
||||
|
||||
* @param limit The maximum number of substrings to return. Zero by default means no limit is set.
|
||||
*/
|
||||
public fun String.split(regex: Pattern, limit: Int = 0): List<String> = regex.split(this, limit).asList()
|
||||
public fun String.split(regex: Pattern, limit: Int = 0): List<String>
|
||||
{
|
||||
require(limit >= 0, { "Limit must be non-negative, but was $limit" } )
|
||||
return regex.split(this, if (limit == 0) -1 else limit).asList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a substring of this string starting with the specified index.
|
||||
|
||||
Reference in New Issue
Block a user