Kotlin Tutorial #16: Sequences — Lazy Collections for Performance

In the previous tutorial, you learned about delegation. Now let’s learn about sequences. Sequences are lazy collections that process elements one at a time instead of all at once. This can make a big difference in performance when working with large data sets. In this tutorial, you will learn: Sequences vs Lists (lazy vs eager) Creating sequences generateSequence Sequence builders with yield and yieldAll Infinite sequences When to use sequences Performance comparison Practical examples Sequences vs Lists Lists are eager — they process all elements at each step and create intermediate collections. Sequences are lazy — they process one element through all steps before moving to the next. ...

March 22, 2026 · 9 min