Collection Operations
map, filter, reduce, sortedBy, groupBy, any, all, sum and take are the daily tools.
Example
val n = listOf(5, 2, 8, 1)
println(n.filter { it > 2 })
println(n.map { it * 2 })
println(n.sorted())
println(n.sortedByDescending { it })
println(n.sum())
println(n.any { it > 7 })
println(n.take(2))Exercise
Keep matches.
n. { it > 2 }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.