← Kotlin Programming learning pathKotlin Programming · Module 6 of 10
Collections
Work with lists, sets and maps using powerful functions.
📖 Key ideas
- listOf (read-only) vs mutableListOf (changeable).
- setOf for unique items; mapOf("a" to 1) for key-value pairs.
- Functions: filter, map, sortedBy, groupBy, sumOf, first, any, all.
- Sequences process large data lazily.
- Destructuring: for ((k, v) in map).
💡 Real-life example: Collection functions are kitchen machines: filter is a sieve, map is a blender, sum is a scale.
listOfRead-only list
mutableListOfChangeable list
filterKeeps matching items
groupByGroups into a map by key