KotlinCollection OpsflatMap
map

flatMapCollection Ops

reduce

Returns a single list of all elements from results of transform applied to each element.

Syntax

collection.flatMap { transform }

Example

Enter values below to update the example in real time.

val
lists
listOf
println
flatMap
it
val lists = listOf(listOf(1, 2), listOf(3, 4))
println(lists.flatMap { it }) // [1, 2, 3, 4]