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.
|
* 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 {
|
public fun CharSequence.take(n: Int): CharSequence {
|
||||||
require(n >= 0) { "Requested character count $n is less than zero." }
|
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.
|
* 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 {
|
public fun String.take(n: Int): String {
|
||||||
require(n >= 0) { "Requested character count $n is less than zero." }
|
require(n >= 0) { "Requested character count $n is less than zero." }
|
||||||
|
|||||||
@@ -191,4 +191,10 @@ class Strings {
|
|||||||
assertPrints("Hot_Tea".commonSuffixWith("Hot_Coffee"), "")
|
assertPrints("Hot_Tea".commonSuffixWith("Hot_Coffee"), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Sample
|
||||||
|
fun take() {
|
||||||
|
val string = "Lorem Ipsum"
|
||||||
|
assertPrints(string.take(5), "Lorem")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,12 +128,14 @@ object Filtering : TemplateGroupBase() {
|
|||||||
include(CharSequences, Strings, ArraysOfUnsigned)
|
include(CharSequences, Strings, ArraysOfUnsigned)
|
||||||
} builder {
|
} builder {
|
||||||
val n = "\$n"
|
val n = "\$n"
|
||||||
doc {
|
doc {
|
||||||
"""
|
"""
|
||||||
Returns a list containing first [n] elements.
|
Returns a list containing first [n] elements.
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
sample("samples.collections.Collections.Transformations.take")
|
specialFor(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
|
sample("samples.collections.Collections.Transformations.take")
|
||||||
|
}
|
||||||
returns("List<T>")
|
returns("List<T>")
|
||||||
body {
|
body {
|
||||||
"""
|
"""
|
||||||
@@ -155,12 +157,13 @@ object Filtering : TemplateGroupBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
specialFor(Strings, CharSequences) {
|
specialFor(Strings, CharSequences) {
|
||||||
|
sample("samples.text.Strings.take")
|
||||||
returns("SELF")
|
returns("SELF")
|
||||||
specialFor(Strings) {
|
specialFor(Strings) {
|
||||||
doc { "Returns a string containing the first [n] characters from this string, or the entire string if this string is shorter."}
|
doc { "Returns a string containing the first [n] characters from this string, or the entire string if this string is shorter." }
|
||||||
}
|
}
|
||||||
specialFor(CharSequences) {
|
specialFor(CharSequences) {
|
||||||
doc { "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."}
|
doc { "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." }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
body(Strings, CharSequences) {
|
body(Strings, CharSequences) {
|
||||||
|
|||||||
Reference in New Issue
Block a user