Kotlin 2 · Collections and lambdas

Create collections

listOf, setOf and mapOf are read-only. Use mutableListOf and friends to change them.

val names = listOf("Ada", "Grace", "Linus")
val ages = mapOf("Ada" to 36, "Grace" to 45)
val tags = mutableSetOf("a")

Official Kotlin 2 documentation

More collections and lambdas commands

All collections and lambdas commands · Kotlin 2 cheatsheet

Was this page helpful?