Kotlin 2 · Collections and lambdas

Transform and filter

Chain operations on collections with lambdas. it names a single parameter.

val lengths = names.map { it.length }
val short = names.filter { it.length <= 3 }
val total = ages.values.sum()

Official Kotlin 2 documentation

More collections and lambdas commands

All collections and lambdas commands · Kotlin 2 cheatsheet

Was this page helpful?