flatten
Returns a single list of all elements from all arrays in the given array.
Samples
import samples.*
import kotlin.test.*
fun main() {
//sampleStart
val deepArray = arrayOf(
arrayOf(1),
arrayOf(2, 3),
arrayOf(4, 5, 6)
)
assertPrints(deepArray.flatten(), "[1, 2, 3, 4, 5, 6]")
//sampleEnd
}
Returns a single list of all elements from all collections in the given collection.
Samples
import samples.*
fun main() {
//sampleStart
val deepList = listOf(listOf(1), listOf(2, 3), listOf(4, 5, 6))
assertPrints(deepList.flatten(), "[1, 2, 3, 4, 5, 6]")
//sampleEnd
}