$> git checkout iterator
Intent
Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.1
Applications
What is an aggregate object? The word aggregate means a whole formed by combining several elements. In programming terms, it’s a collection, array, list, etc. Why use an aggregate object, though? You can already aggregate a bunch of numbers, strings, or objects all sequentially using arrays. Why do you need the iterator pattern? Is this a useless pattern? The answer is no.
There are some benefits you gain from using an iterator object. ...