<div dir="ltr"><div dir="ltr">Alex Otenko <<a href="mailto:oleksandr.otenko@gmail.com">oleksandr.otenko@gmail.com</a>> ezt írta (időpont: 2023. júl. 3., H, 12:29):<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Well, convenient or not, closing is necessary. How else can a generator tell the consumer that no more values are forthcoming?<div dir="auto"><br></div></div></blockquote><div><br></div><div>From the generator side there is no issue, and closing is also not an issue, since the code just returns which clearly signals the end of the iteration, and after that `hasNext` will just return false.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="auto"></div><div dir="auto">Ditto for closing the channel by the consumer. Barring advanced cases with sharing the generator, you can have try-with-resources take care of closing things for you.</div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br></blockquote></div></blockquote><div><br></div><div>It shouldn't be necessary for a generator, because the `Iterator` eventually becomes unreachable, so everything should be eligible for garbage collection, including the continuation.</div><div> </div></div></div>