diff --git a/libraries/stdlib/common/src/generated/_Strings.kt b/libraries/stdlib/common/src/generated/_Strings.kt index c6694812b64..8841cf7b1e9 100644 --- a/libraries/stdlib/common/src/generated/_Strings.kt +++ b/libraries/stdlib/common/src/generated/_Strings.kt @@ -1456,7 +1456,7 @@ public inline fun CharSequence.sumByDouble(selector: (Char) -> Double): Double { * * @param size the number of elements to take in each string, must be positive and can be greater than the number of elements in this char sequence. * - * @sample samples.collections.Collections.Transformations.chunked + * @sample samples.text.Strings.chunked */ @SinceKotlin("1.2") public fun CharSequence.chunked(size: Int): List { diff --git a/libraries/stdlib/samples/test/samples/text/strings.kt b/libraries/stdlib/samples/test/samples/text/strings.kt index fa925bf1ce5..2e33658afb5 100644 --- a/libraries/stdlib/samples/test/samples/text/strings.kt +++ b/libraries/stdlib/samples/test/samples/text/strings.kt @@ -49,6 +49,15 @@ class Strings { assertPrints(withoutMargin2, "XYZ\nfoo\nbar") } + @Sample + fun chunked() { + val dnaFragment = "ATTCGCGGCCGCCAA" + + val codons = dnaFragment.chunked(3) + + assertPrints(codons, "[ATT, CGC, GGC, CGC, CAA]") + } + @Sample fun chunkedTransform() { val codonTable = mapOf("ATT" to "Isoleucine", "CAA" to "Glutamine", "CGC" to "Arginine", "GGC" to "Glycine") diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index 5b32a5c4fa5..1e644d07bdf 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -868,7 +868,8 @@ object Generators : TemplateGroupBase() { @param size the number of elements to take in each ${f.snapshotResult}, must be positive and can be greater than the number of elements in this ${f.collection}. """ } - sample("samples.collections.Collections.Transformations.chunked") + specialFor(Iterables, Sequences) { sample("samples.collections.Collections.Transformations.chunked") } + specialFor(CharSequences) { sample("samples.text.Strings.chunked") } specialFor(Iterables) { returns("List>") } specialFor(Sequences) { returns("Sequence>") } specialFor(CharSequences) { returns("List") }