Understand Each Iteration Inside a Generator

Share this video with your friends

Send Tweet

A clear understanding of how iterations are defined and execute inside a generator is essentially to being able to use them properly. Each next call on the iterator runs inside the generator until it reaches a yield statement then the generator pauses until next is called again. When a next is called and no yield is found, then the generator assumes it is done.