Getting ready
Kotlin standard library provides two basic interfaces which represent collection data structure—Collection and MutableCollection, both extending the Iterable interface. The first one defines an immutable collection that only supports read access to its elements. The second interface allows us to both add and remove elements. There are also more specialized interfaces that extend the Collection and MutableCollection base types, such as List, MutableList, Set, and MutableSet.
There are many functions available for creating collections of different types. The most commonly used ones are the <T> listOf(vararg elements: T) function, which instantiates a List instance, and <T> mutableListOf(vararg elements: T), which returns an instance ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access