flatMap
@ExperimentalUnsignedTypes inline fun <R> ULongArray.flatMap(
transform: (ULong) -> Iterable<R>
): List<R>
(source)
@ExperimentalUnsignedTypes inline fun <R> UByteArray.flatMap(
transform: (UByte) -> Iterable<R>
): List<R>
(source)
@ExperimentalUnsignedTypes inline fun <R> UShortArray.flatMap(
transform: (UShort) -> Iterable<R>
): List<R>
(source)
Returns a single list of all elements yielded from results of transform function being invoked on each element of original array.
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
val list = listOf("123", "45")
println(list.flatMap { it.toList() }) // [1, 2, 3, 4, 5]
//sampleEnd
}
Returns a single list of all elements yielded from results of transform function being invoked on each element of original collection.
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
val list = listOf("123", "45")
println(list.flatMap { it.toList() }) // [1, 2, 3, 4, 5]
//sampleEnd
}
Returns a single list of all elements yielded from results of transform function being invoked on each entry of original map.
import kotlin.test.*
import java.util.*
fun main(args: Array<String>) {
//sampleStart
val map = mapOf("122" to 2, "3455" to 3)
println(map.flatMap { (key, value) -> key.take(value).toList() }) // [1, 2, 3, 4, 5]
//sampleEnd
}
Returns a single list of all elements yielded from results of transform function being invoked on each entry of original map.
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
val list = listOf("123", "45")
println(list.flatMap { it.toList() }) // [1, 2, 3, 4, 5]
//sampleEnd
}