kbox / ch.tutteli.kbox / kotlin.collections.List

Extensions for kotlin.collections.List

appendToStringBuilder

fun <T> List<T>.appendToStringBuilder(sb: StringBuilder, separator: String, append: (it: T, StringBuilder) -> Unit): Unit

Appends all elements of this list to the given sb by calling append and separates the elements with the given separator.

fun <T> List<T>.appendToStringBuilder(sb: StringBuilder, separator: String, lastSeparator: String, append: (it: T, StringBuilder) -> Unit): Unit

Appends all elements of this list to the given sb by calling append and separates the elements with the given separator whereas lastSeparator is used to separate the last and the second last element.

flatten

fun <T, T2> List<T>.flatten(getter: (it: T) -> List<T2>): List<T2>

joinToString

fun <T> List<T>.joinToString(separator: String, append: (it: T, StringBuilder) -> Unit): String

Joins all elements of this list by calling append and separates the elements with the given separator.

fun <T> List<T>.joinToString(separator: String, lastSeparator: String, append: (it: T, StringBuilder) -> Unit): String

Joins all elements of this list by calling append and separates the elements with the given separator whereas lastSeparator is used to separate the last and the second last element.