Sequences: Why We Need Them

A practical example demonstrating how collections based on Iterable fall short, a novel explanation of why this happens using traversal precedence, and showing how Sequence naturally arises from this view.

Gabriel Shanahan
The Kotlin Primer

--

— — — — — — — — — — — — — — —

THE CURRENT VERSION OF THIS ARTICLE IS PUBLISHED HERE.

— — — — — — — — — — — — — — —

Tags: #FYI++

This article is part of the Kotlin Primer, an opinionated guide to the Kotlin language, which is indented to help facilitate Kotlin adoption inside Java-centric organizations. It was originally written as an organizational learning resource for Etnetera a.s. and I would like to express my sincere gratitude for their support.

It is recommended to read the Introduction before moving on. Check out the Table of Contents for all articles.

The Sequence interface, and it’s inheritors, form a completely separate collection hierarchy from the one we’ve been talking about until now (List, Set etc.), which is based on Iterable. In this article, we’ll give an example that demonstrates how what we’ve learned so far can…

--

--