0Pricing
Kotlin Academy · Lesson

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

  1. listOf, setOf, mapOf: Read-Only Collections
  2. mutableListOf, mutableMapOf: Mutable Builders
  3. Accessing Elements: get, first, last, getOrNull
  4. Iterating and Transforming Collections with Standard Library
← Back to Kotlin Academy