Great article Steve, especially that you found a real world use case of making a custom iterable object. I had similar fun while writing How I learned to Stop Looping and Love the Iterator, though I wish I could add a section on generators.
One suggestion for you to improve the iterator of your se7enDwarves, is that you can redirect iteration to another iterable using yield *:
Spencerian script, hand-stitched bookbinding, wax seals, coaching new crafters, helping people change their lives for the better.
Despiser of complacency and maintenance mode.
Thanks, Kushan. I did realize that the iterator could be simplified about a month after I wrote the original article, but never updated it, so thanks for posting what that looks like. Great stuff.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great article Steve, especially that you found a real world use case of making a custom iterable object. I had similar fun while writing How I learned to Stop Looping and Love the Iterator, though I wish I could add a section on generators.
One suggestion for you to improve the iterator of your
se7enDwarves
, is that you can redirect iteration to another iterable using yield *:Thanks, Kushan. I did realize that the iterator could be simplified about a month after I wrote the original article, but never updated it, so thanks for posting what that looks like. Great stuff.