4.1 Iterator

Most languages provide mechanisms to easily iterate, or loop over, collections of objects. What if you need to create a class that has some internal components that you want to iterate over in a simple way? That could be complicated, but not with the iterator pattern. And with some of Swift's built-in protocols, it's even easier.