@JvmName("flatMapIterable") fun <T, R> Sequence<T>.flatMap( transform: (T) -> Iterable<R> ): Sequence<R>
fun <T, R> Sequence<T>.flatMap( transform: (T) -> Sequence<R> ): Sequence<R>
Returns a single sequence of all elements from results of transform function being invoked on each element of original sequence.
The operation is intermediate and stateless.
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
}
© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/flat-map.html