Sequences
In Chapter 9 and Chapter 10, you were introduced to the collection types List, Set, and Map. These collection types are all known as eager collections. When an instance of any of these types is created, all the values it contains are added to the collection and can be accessed.
There is another flavor of collection: lazy collections. The term lazy indicates that a value is not created until the first time it is requested. Lazy collection types can provide better performance – especially when working with very large collections – because their values are produced only as needed.
Kotlin offers a built-in lazy collection type called Sequence. Sequences do not index their contents, and they do not keep track of their size. ...
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