You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
The cause here is that array iterators aren't closable, unlike generators. I think that was probably a mistake; they should have been, which would have made these consistent (by having the first snippet behave like the second). Unfortunately it may be too late to change now. It was never going to be practical to have the second snippet behave like the first, because iterator helpers can wrap closable things and so need to be closable.
Either way, you should avoid re-using iterators. They're really designed to be single-use. Once you call a helper method, you should stop holding on to the original thing.
At the intuitive level, I don't expect these to behave differently, it feels like an arbitrary distinction in this case.
The alternative of repeating the
map
(and/orflatMap
,filter
) call feels clunky, even if it's most likely to be done in a loop:With the chunking proposal in the works maybe this particular case isn't very compelling, but I thought I'd bring it up anyway.
The text was updated successfully, but these errors were encountered: