# Is it always safe to “re-use” an iterator/generator?

**URL:** <https://discourse.julialang.org/t/is-it-always-safe-to-re-use-an-iterator-generator/95697>\
**Category:** General Usage\
**Tags:** generator, iterators\
**Created:** [March 7, 2023, 9:39pm UTC](https://discourse.julialang.org/t/is-it-always-safe-to-re-use-an-iterator-generator/95697 "2023-03-07T21:39:29Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![lmtzx9h4qqnt](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@lmtzx9h4qqnt](https://discourse.julialang.org/u/lmtzx9h4qqnt)\
**Post date:** [March 15, 2023, 2:21am UTC](https://discourse.julialang.org/t/is-it-always-safe-to-re-use-an-iterator-generator/95697/10 "2023-03-15T02:21:05Z")

</div>

A relevant previous discussion:

> [@Iterators.Stateful is not an iterator?](https://discourse.julialang.org/t/iterators-stateful-is-not-an-iterator/53080):
>
> I’m trying to understand iterators better because I’m trying to decide whether I should, for my specific application, define iterate for my type or define a constructor of Iterators.Stateful for my type. And I seem to have reached the conclusion that Iterators.Stateful aren’t iterators? The interfaces page [[1]](https://docs.julialang.org/en/v1/manual/interfaces/) says that to implement the interator interface, two methods are required: iterate(iter) Returns either a tuple of the first item and initial state or [nothing](https://docs.julialang.org/en/v1/base/constants/#Core.nothing) if empty iterate(iter, …

---

_[View the full topic](https://discourse.julialang.org/t/is-it-always-safe-to-re-use-an-iterator-generator/95697)._
