What is the difference between an Iterator and a Generator? - Stack Overflow

An iterator traverses a collection one at a time.

A generator generates a sequence, one item at a time.

You might for example, iterate over the result of a generator...

Generators are iterators, but not all iterators are generators.

An iterator is typically something that has a next method to get the next element from a stream. A generator is an iterator that is tied to a function.

A generator is an implementation of an iterator.

 王小旺 
@ 
@ 其實我沒仔細研究過,我的理解是:「iterator」是用途、「generator」是作法。 :/