Manipulating collections

Throughout this book, we've been making use of collections within our examples. The Kotlin standard library provides helper functions that make the creation of common collection types very easy:

fun main() {
val list = listOf("Kotlin", "Java", "Swift")
val mutableList = mutableListOf("Kotlin", "Java", "Swift")
val arrayList = arrayListOf("Kotlin", "Java", "Swift")
val array = arrayOf("Kotlin", "Java", "Swift")
val map = mapOf("Kotlin" to 1, "Java" to 2, "Swift" to 3)
}

The Kotlin standard library provides numerous functions for working with these collection types once they are created. Through operations such as filter, map, reduce, and find, we can write powerful functional chains that can perform complex tasks with little code.

In this section, we will explore some of these functions and how to make use of the Kotlin standard library.