โ† Kotlin Programming learning path
Kotlin Programming ยท Module 6 of 10

Collections

Work with lists, sets and maps using powerful functions.

๐Ÿ“– Key ideas

  1. listOf (read-only) vs mutableListOf (changeable).
  2. setOf for unique items; mapOf("a" to 1) for key-value pairs.
  3. Functions: filter, map, sortedBy, groupBy, sumOf, first, any, all.
  4. Sequences process large data lazily.
  5. 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