Iterating and Transforming Collections with Standard Library
Use map, filter, any, all, count on real collection examples.
Collections as Pipelines
Kotlin's standard library transforms collections through chained operations. Each function returns a new collection — the original is untouched.
map: One-to-One Transformation
map applies a function to each element and returns a list of results.
val prices = listOf(10, 20, 30)
val withTax = prices.map { it * 1.1 }
println(withTax) // [11.0, 22.0, 33.0]All lessons in this course
- listOf, setOf, mapOf: Read-Only Collections
- mutableListOf, mutableMapOf: Mutable Builders
- Accessing Elements: get, first, last, getOrNull
- Iterating and Transforming Collections with Standard Library