From 40e3159463d7041cd149ddf6e90dd0baef70e83f Mon Sep 17 00:00:00 2001 From: gzoritchak Date: Sun, 11 Feb 2018 00:16:41 +0100 Subject: [PATCH] Add samples for joinToString KT-20357 --- .../src/core/generated/_ArraysJs.kt | 18 +++++++ .../src/core/generated/_CollectionsJs.kt | 2 + .../src/core/generated/_SequencesJs.kt | 2 + .../stdlib/common/src/generated/_Arrays.kt | 18 +++++++ .../common/src/generated/_Collections.kt | 2 + .../stdlib/common/src/generated/_Sequences.kt | 2 + .../test/samples/collections/collections.kt | 11 ++++ libraries/stdlib/src/generated/_Arrays.kt | 50 +++++++++++++++++++ .../stdlib/src/generated/_Collections.kt | 2 + libraries/stdlib/src/generated/_Sequences.kt | 4 ++ .../src/templates/Strings.kt | 2 + 11 files changed, 113 insertions(+) diff --git a/js/js.libraries/src/core/generated/_ArraysJs.kt b/js/js.libraries/src/core/generated/_ArraysJs.kt index c3c860aab65..50c726dc3f0 100644 --- a/js/js.libraries/src/core/generated/_ArraysJs.kt +++ b/js/js.libraries/src/core/generated/_ArraysJs.kt @@ -13066,6 +13066,8 @@ public fun CharArray.joinTo(buffer: A, separator: CharSequence * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun Array.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13076,6 +13078,8 @@ public fun Array.joinToString(separator: CharSequence = ", ", prefix: * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun ByteArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Byte) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13086,6 +13090,8 @@ public fun ByteArray.joinToString(separator: CharSequence = ", ", prefix: CharSe * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun ShortArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Short) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13096,6 +13102,8 @@ public fun ShortArray.joinToString(separator: CharSequence = ", ", prefix: CharS * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun IntArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Int) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13106,6 +13114,8 @@ public fun IntArray.joinToString(separator: CharSequence = ", ", prefix: CharSeq * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun LongArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Long) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13116,6 +13126,8 @@ public fun LongArray.joinToString(separator: CharSequence = ", ", prefix: CharSe * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun FloatArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Float) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13126,6 +13138,8 @@ public fun FloatArray.joinToString(separator: CharSequence = ", ", prefix: CharS * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun DoubleArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Double) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13136,6 +13150,8 @@ public fun DoubleArray.joinToString(separator: CharSequence = ", ", prefix: Char * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun BooleanArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Boolean) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13146,6 +13162,8 @@ public fun BooleanArray.joinToString(separator: CharSequence = ", ", prefix: Cha * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun CharArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Char) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() diff --git a/js/js.libraries/src/core/generated/_CollectionsJs.kt b/js/js.libraries/src/core/generated/_CollectionsJs.kt index f1209c165b7..57de8cb46ab 100644 --- a/js/js.libraries/src/core/generated/_CollectionsJs.kt +++ b/js/js.libraries/src/core/generated/_CollectionsJs.kt @@ -2167,6 +2167,8 @@ public fun Iterable.joinTo(buffer: A, separator: CharSequ * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun Iterable.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() diff --git a/js/js.libraries/src/core/generated/_SequencesJs.kt b/js/js.libraries/src/core/generated/_SequencesJs.kt index 2cadfb38dfd..c9deea36152 100644 --- a/js/js.libraries/src/core/generated/_SequencesJs.kt +++ b/js/js.libraries/src/core/generated/_SequencesJs.kt @@ -1629,6 +1629,8 @@ public fun Sequence.joinTo(buffer: A, separator: CharSequ * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString * * The operation is _terminal_. */ diff --git a/libraries/stdlib/common/src/generated/_Arrays.kt b/libraries/stdlib/common/src/generated/_Arrays.kt index 1e2f168fa30..6576be00200 100644 --- a/libraries/stdlib/common/src/generated/_Arrays.kt +++ b/libraries/stdlib/common/src/generated/_Arrays.kt @@ -7436,6 +7436,8 @@ public fun CharArray.joinTo(buffer: A, separator: CharSequence * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun Array.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -7446,6 +7448,8 @@ public fun Array.joinToString(separator: CharSequence = ", ", prefix: * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun ByteArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Byte) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -7456,6 +7460,8 @@ public fun ByteArray.joinToString(separator: CharSequence = ", ", prefix: CharSe * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun ShortArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Short) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -7466,6 +7472,8 @@ public fun ShortArray.joinToString(separator: CharSequence = ", ", prefix: CharS * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun IntArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Int) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -7476,6 +7484,8 @@ public fun IntArray.joinToString(separator: CharSequence = ", ", prefix: CharSeq * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun LongArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Long) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -7486,6 +7496,8 @@ public fun LongArray.joinToString(separator: CharSequence = ", ", prefix: CharSe * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun FloatArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Float) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -7496,6 +7508,8 @@ public fun FloatArray.joinToString(separator: CharSequence = ", ", prefix: CharS * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun DoubleArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Double) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -7506,6 +7520,8 @@ public fun DoubleArray.joinToString(separator: CharSequence = ", ", prefix: Char * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun BooleanArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Boolean) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -7516,6 +7532,8 @@ public fun BooleanArray.joinToString(separator: CharSequence = ", ", prefix: Cha * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun CharArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Char) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() diff --git a/libraries/stdlib/common/src/generated/_Collections.kt b/libraries/stdlib/common/src/generated/_Collections.kt index e1a2f23c91f..fd5984d72d3 100644 --- a/libraries/stdlib/common/src/generated/_Collections.kt +++ b/libraries/stdlib/common/src/generated/_Collections.kt @@ -1155,6 +1155,8 @@ public fun Iterable.joinTo(buffer: A, separator: CharSequ * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun Iterable.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() diff --git a/libraries/stdlib/common/src/generated/_Sequences.kt b/libraries/stdlib/common/src/generated/_Sequences.kt index 63b2e11cf29..ad48b96b77f 100644 --- a/libraries/stdlib/common/src/generated/_Sequences.kt +++ b/libraries/stdlib/common/src/generated/_Sequences.kt @@ -1045,6 +1045,8 @@ public fun Sequence.joinTo(buffer: A, separator: CharSequ * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString * * The operation is _terminal_. */ diff --git a/libraries/stdlib/samples/test/samples/collections/collections.kt b/libraries/stdlib/samples/test/samples/collections/collections.kt index d402e579706..1c8a766790f 100644 --- a/libraries/stdlib/samples/test/samples/collections/collections.kt +++ b/libraries/stdlib/samples/test/samples/collections/collections.kt @@ -311,6 +311,17 @@ class Collections { assertPrints(moreFrequencies, "{o=1, t=4, f=2, s=2, e=2, n=1}") } + @Sample + fun joinToString() { + val numbers = listOf(1, 2, 3, 4, 5, 6) + assertPrints(numbers.joinToString(), "1, 2, 3, 4, 5, 6") + assertPrints(numbers.joinToString(prefix = "[", postfix = "]"), "[1, 2, 3, 4, 5, 6]") + assertPrints(numbers.joinToString(prefix = "<", postfix = ">", separator = "•"), "<1•2•3•4•5•6>") + + val chars = charArrayOf('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q') + assertPrints(chars.joinToString(limit = 5, truncated = "...!") { it.toUpperCase().toString() }, "A, B, C, D, E, ...!") + } + @Sample fun chunked() { val words = "one two three four five six seven eight nine ten".split(' ') diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 0bb930ac266..6769c8edca9 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -13502,6 +13502,12 @@ public fun CharArray.joinTo(buffer: A, separator: CharSequence * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). +<<<<<<< HEAD + * +======= + * +>>>>>>> b371fcfd5d9... Add samples for joinToString + * @sample samples.collections.Collections.Transformations.joinToString */ public fun Array.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13512,6 +13518,12 @@ public fun Array.joinToString(separator: CharSequence = ", ", prefix: * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). +<<<<<<< HEAD + * +======= + * +>>>>>>> b371fcfd5d9... Add samples for joinToString + * @sample samples.collections.Collections.Transformations.joinToString */ public fun ByteArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Byte) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13522,6 +13534,12 @@ public fun ByteArray.joinToString(separator: CharSequence = ", ", prefix: CharSe * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). +<<<<<<< HEAD + * +======= + * +>>>>>>> b371fcfd5d9... Add samples for joinToString + * @sample samples.collections.Collections.Transformations.joinToString */ public fun ShortArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Short) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13532,6 +13550,12 @@ public fun ShortArray.joinToString(separator: CharSequence = ", ", prefix: CharS * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). +<<<<<<< HEAD + * +======= + * +>>>>>>> b371fcfd5d9... Add samples for joinToString + * @sample samples.collections.Collections.Transformations.joinToString */ public fun IntArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Int) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13542,6 +13566,12 @@ public fun IntArray.joinToString(separator: CharSequence = ", ", prefix: CharSeq * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). +<<<<<<< HEAD + * +======= + * +>>>>>>> b371fcfd5d9... Add samples for joinToString + * @sample samples.collections.Collections.Transformations.joinToString */ public fun LongArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Long) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13552,6 +13582,12 @@ public fun LongArray.joinToString(separator: CharSequence = ", ", prefix: CharSe * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). +<<<<<<< HEAD + * +======= + * +>>>>>>> b371fcfd5d9... Add samples for joinToString + * @sample samples.collections.Collections.Transformations.joinToString */ public fun FloatArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Float) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13562,6 +13598,12 @@ public fun FloatArray.joinToString(separator: CharSequence = ", ", prefix: CharS * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). +<<<<<<< HEAD + * +======= + * +>>>>>>> b371fcfd5d9... Add samples for joinToString + * @sample samples.collections.Collections.Transformations.joinToString */ public fun DoubleArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Double) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13572,6 +13614,12 @@ public fun DoubleArray.joinToString(separator: CharSequence = ", ", prefix: Char * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). +<<<<<<< HEAD + * +======= + * +>>>>>>> b371fcfd5d9... Add samples for joinToString + * @sample samples.collections.Collections.Transformations.joinToString */ public fun BooleanArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Boolean) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() @@ -13582,6 +13630,8 @@ public fun BooleanArray.joinToString(separator: CharSequence = ", ", prefix: Cha * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun CharArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Char) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index ff0718f8f9b..3b3e6b1d79f 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -2191,6 +2191,8 @@ public fun Iterable.joinTo(buffer: A, separator: CharSequ * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun Iterable.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index 3fc92014172..02307026566 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -1670,8 +1670,12 @@ public fun Sequence.joinTo(buffer: A, separator: CharSequ * * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). + * + * @sample samples.collections.Collections.Transformations.joinToString * * The operation is _terminal_. + * + * @sample samples.collections.Collections.Transformations.joinToString */ public fun Sequence.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt index f5617f95d82..f0138afa2c1 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt @@ -79,6 +79,8 @@ object StringJoinOps : TemplateGroupBase() { If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] elements will be appended, followed by the [truncated] string (which defaults to "..."). + + @sample samples.collections.Collections.Transformations.joinToString """ } sequenceClassification(terminal)