What are the main differences between `Iterator` a...
# announcements
c
What are the main differences between
Iterator
and
Sequence
?
A Sequence can be transformed into an Iterator, even though it doesn't implement the Iterable interface.
m
So why is there special class instead of just using Iterable?
s
Why is there a Sequence interface/class?
Sequences are lazy, non-eager and immutable (no remove() on its Iterator).
Because of this, the hasNext() method of the Iterator from a Sequence may have some side-effects.
👍 1
f
Iterator
in Kotlin has no
remove
either, you would need to implement
MutableIterator
. 😉
💯 1
c
@streetsofboston does that mean Iterator is eager?
s
I meant ‘eager’ as the opposite of ‘lazy’. 🙂