From the course: Kotlin Essential Training: Functions, Collections, and I/O
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Working with collections - Kotlin Tutorial
From the course: Kotlin Essential Training: Functions, Collections, and I/O
Working with collections
- [Instructor] While collections such as list, set, or map are useful in their own right, the Kotlin Standard Library provides many useful helper functions that add even greater programming power to these collection types. We're going to explore how to take full advantage of the Kotlin Standard Library as we learn to transform and query common collection types. There are a number of common patterns across collection types that help make the collections easier to learn and work with. Need to create a read only data structure, we can use our listOf, setOf, and mapOf functions. So like we've seen, we could create a readOnlyList by invoking the listOf function. We could create a readOnlySet by invoking a setOf or readOnlyMap by using the mapOf function. And like we've seen if we need immutable versions of these common data structures, there are builder functions for those as well. If we simply copy these first three examples,…