Add samples for joinToString
KT-20357
This commit is contained in:
@@ -13066,6 +13066,8 @@ public fun <A : Appendable> 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]
|
* 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 "...").
|
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||||
|
*
|
||||||
|
* @sample samples.collections.Collections.Transformations.joinToString
|
||||||
*/
|
*/
|
||||||
public fun <T> Array<out T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
public fun <T> Array<out T>.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()
|
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
|
||||||
@@ -13076,6 +13078,8 @@ public fun <T> Array<out T>.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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
|
||||||
|
|||||||
@@ -2167,6 +2167,8 @@ public fun <T, A : Appendable> Iterable<T>.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]
|
* 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 "...").
|
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||||
|
*
|
||||||
|
* @sample samples.collections.Collections.Transformations.joinToString
|
||||||
*/
|
*/
|
||||||
public fun <T> Iterable<T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
public fun <T> Iterable<T>.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()
|
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
|
||||||
|
|||||||
@@ -1630,6 +1630,8 @@ public fun <T, A : Appendable> Sequence<T>.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]
|
* 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 "...").
|
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||||
*
|
*
|
||||||
|
* @sample samples.collections.Collections.Transformations.joinToString
|
||||||
|
*
|
||||||
* The operation is _terminal_.
|
* The operation is _terminal_.
|
||||||
*/
|
*/
|
||||||
public fun <T> Sequence<T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
public fun <T> Sequence<T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
||||||
|
|||||||
@@ -7436,6 +7436,8 @@ public fun <A : Appendable> 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]
|
* 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 "...").
|
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||||
|
*
|
||||||
|
* @sample samples.collections.Collections.Transformations.joinToString
|
||||||
*/
|
*/
|
||||||
public fun <T> Array<out T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
public fun <T> Array<out T>.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()
|
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
|
||||||
@@ -7446,6 +7448,8 @@ public fun <T> Array<out T>.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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
|
||||||
|
|||||||
@@ -1155,6 +1155,8 @@ public fun <T, A : Appendable> Iterable<T>.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]
|
* 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 "...").
|
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||||
|
*
|
||||||
|
* @sample samples.collections.Collections.Transformations.joinToString
|
||||||
*/
|
*/
|
||||||
public fun <T> Iterable<T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
public fun <T> Iterable<T>.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()
|
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
|
||||||
|
|||||||
@@ -1046,6 +1046,8 @@ public fun <T, A : Appendable> Sequence<T>.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]
|
* 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 "...").
|
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||||
*
|
*
|
||||||
|
* @sample samples.collections.Collections.Transformations.joinToString
|
||||||
|
*
|
||||||
* The operation is _terminal_.
|
* The operation is _terminal_.
|
||||||
*/
|
*/
|
||||||
public fun <T> Sequence<T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
public fun <T> Sequence<T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
||||||
|
|||||||
@@ -311,6 +311,17 @@ class Collections {
|
|||||||
assertPrints(moreFrequencies, "{o=1, t=4, f=2, s=2, e=2, n=1}")
|
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
|
@Sample
|
||||||
fun chunked() {
|
fun chunked() {
|
||||||
val words = "one two three four five six seven eight nine ten".split(' ')
|
val words = "one two three four five six seven eight nine ten".split(' ')
|
||||||
|
|||||||
@@ -13502,6 +13502,12 @@ public fun <A : Appendable> 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]
|
* 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 "...").
|
* 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 <T> Array<out T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
public fun <T> Array<out T>.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()
|
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
|
||||||
@@ -13512,6 +13518,12 @@ public fun <T> Array<out T>.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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
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]
|
* 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 "...").
|
* 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 {
|
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()
|
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
|
||||||
|
|||||||
@@ -2191,6 +2191,8 @@ public fun <T, A : Appendable> Iterable<T>.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]
|
* 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 "...").
|
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||||
|
*
|
||||||
|
* @sample samples.collections.Collections.Transformations.joinToString
|
||||||
*/
|
*/
|
||||||
public fun <T> Iterable<T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
public fun <T> Iterable<T>.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()
|
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
|
||||||
|
|||||||
@@ -1671,7 +1671,11 @@ public fun <T, A : Appendable> Sequence<T>.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]
|
* 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 "...").
|
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||||
*
|
*
|
||||||
|
* @sample samples.collections.Collections.Transformations.joinToString
|
||||||
|
*
|
||||||
* The operation is _terminal_.
|
* The operation is _terminal_.
|
||||||
|
*
|
||||||
|
* @sample samples.collections.Collections.Transformations.joinToString
|
||||||
*/
|
*/
|
||||||
public fun <T> Sequence<T>.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
|
public fun <T> Sequence<T>.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()
|
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
|
||||||
|
|||||||
@@ -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]
|
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 "...").
|
elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||||
|
|
||||||
|
@sample samples.collections.Collections.Transformations.joinToString
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
sequenceClassification(terminal)
|
sequenceClassification(terminal)
|
||||||
|
|||||||
Reference in New Issue
Block a user