6 Working with collections and sequences
This chapter covers
- Working with collections in a functional style
- Sequences: performing collection operations lazily
In chapter 5, you learned about lambdas as a way of passing small blocks of code to other functions. One of the most common uses for lambdas is working with collections. In this chapter, you will see how replacing common collection access patterns with a combination of standard library functions and your own lambdas can make your code more expressive, elegant, and concise—whether you are filtering your data based on predicates, need to group data, or want to transform collection items from one form to another.
You will also explore sequences as an alternative way to apply multiple collection ...
Get Kotlin in Action, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.