KT-29151 Fix the problematic pages - CharSequence.take() & String.take()
This commit is contained in:
committed by
Ilya Gorbunov
parent
0f45e3d238
commit
991e739693
@@ -455,7 +455,7 @@ public inline fun String.slice(indices: Iterable<Int>): String {
|
||||
/**
|
||||
* Returns a subsequence of this char sequence containing the first [n] characters from this char sequence, or the entire char sequence if this char sequence is shorter.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
* @sample samples.text.Strings.take
|
||||
*/
|
||||
public fun CharSequence.take(n: Int): CharSequence {
|
||||
require(n >= 0) { "Requested character count $n is less than zero." }
|
||||
@@ -465,7 +465,7 @@ public fun CharSequence.take(n: Int): CharSequence {
|
||||
/**
|
||||
* Returns a string containing the first [n] characters from this string, or the entire string if this string is shorter.
|
||||
*
|
||||
* @sample samples.collections.Collections.Transformations.take
|
||||
* @sample samples.text.Strings.take
|
||||
*/
|
||||
public fun String.take(n: Int): String {
|
||||
require(n >= 0) { "Requested character count $n is less than zero." }
|
||||
|
||||
@@ -191,4 +191,10 @@ class Strings {
|
||||
assertPrints("Hot_Tea".commonSuffixWith("Hot_Coffee"), "")
|
||||
}
|
||||
|
||||
@Sample
|
||||
fun take() {
|
||||
val string = "Lorem Ipsum"
|
||||
assertPrints(string.take(5), "Lorem")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user