Improve docs for substring/subsequence.
This commit is contained in:
@@ -277,23 +277,26 @@ public fun CharSequence.hasSurrogatePairAt(index: Int): Boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a substring specified by the given [range].
|
||||
* Returns a substring specified by the given [range] of indices.
|
||||
*/
|
||||
public fun String.substring(range: IntRange): String = substring(range.start, range.endInclusive + 1)
|
||||
|
||||
/**
|
||||
* Returns a subsequence of this char sequence specified by the given [range].
|
||||
* Returns a subsequence of this char sequence specified by the given [range] of indices.
|
||||
*/
|
||||
public fun CharSequence.subSequence(range: IntRange): CharSequence = subSequence(range.start, range.endInclusive + 1)
|
||||
|
||||
/**
|
||||
* Returns a substring of chars from a range of this char sequence specified by [startIndex] and [endIndex] indices.
|
||||
* Returns a substring of chars from a range of this char sequence starting at the [startIndex] and ending right before the [endIndex].
|
||||
*
|
||||
* @param startIndex the start index (inclusive).
|
||||
* @param endIndex the end index (exclusive). If not specified, the length of the char sequence is used.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharSequence.substring(startIndex: Int, endIndex: Int = length): String = subSequence(startIndex, endIndex).toString()
|
||||
|
||||
/**
|
||||
* Returns a substring of chars from a [range] of this char sequence.
|
||||
* Returns a substring of chars at indices from the specified [range] of this char sequence.
|
||||
*/
|
||||
public fun CharSequence.substring(range: IntRange): String = subSequence(range.start, range.endInclusive + 1).toString()
|
||||
|
||||
|
||||
@@ -156,13 +156,16 @@ public fun CharSequence.split(regex: Pattern, limit: Int = 0): List<String>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a substring of this string starting with the specified index.
|
||||
* Returns a substring of this string that starts at the specified [startIndex] and continues to the end of the string.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.substring(startIndex: Int): String = (this as java.lang.String).substring(startIndex)
|
||||
|
||||
/**
|
||||
* Returns the substring of this string starting and ending at the specified indices.
|
||||
* Returns the substring of this string starting at the [startIndex] and ending right before the [endIndex].
|
||||
*
|
||||
* @param startIndex the start index (inclusive).
|
||||
* @param endIndex the end index (exclusive).
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.substring(startIndex: Int, endIndex: Int): String = (this as java.lang.String).substring(startIndex, endIndex)
|
||||
|
||||
Reference in New Issue
Block a user