Stefan Jibrail Froelich - 2016-10-12 08:54:21
It pains me to say this, but this article is not only poorly written, it's not properly researched and misleading as well.
Iterators do not replace loops. Iterators are used in loops.
A simple example foreach. It manages the Iterator by calling the necessary methods such as next().
In order to iterate, you can manually call next() on your Iterator but that means you can only process a set number of items.
This article demonstrates a poor knowledge of what loops are.
A loop simple means, do this thing a number of times until my condition is met. In many cases, this means, go through all the data in my structure until all items are processed.
Yes, iterators do make your life easier especially when you need to do some complex stuff like filter, or as in the article nest iterations, but they are NOT a replacement for loops.
And btw, generators are not a way to iterate. They are a lazy way to (as the name suggests), generate data.
I would point you to both my articles on iterators and generators on sitepoint but that's not allowed on this site.