3 ms·
> Every time we iterate over numbers, it will start over at the beginning of the iterator method and yield all the same values over again. (You can’t expect thi
by sdfhdhjdw3 4y ago
> Every time we iterate over numbers, it will start over at the beginning of the iterator method and yield all the same values over again. (You can’t expect this from every iterator; more on that later.)
They never did, or did I miss it?
- hddqsb 4y agoThey did: > An iterator could query a database, for example—including the unfortunate possibility that it might alter data, or that iterating through it twice might yield completely different results! Some tools (like ReSharper) will warn you against multiple enumeration for this reason.
- sdfhdhjdw3 4y agoOh I saw that. I was expecting that they were gonna discuss stateful iterators more generally. Database iterators are just a tiny subset of stateful iterators. I think discussing the latter more generally would have been more useful than a one-liner about databases.