foreach() behavior on ranges

frame frame86 at live.com
Tue Aug 24 18:15:42 UTC 2021


On Tuesday, 24 August 2021 at 16:45:27 UTC, H. S. Teoh wrote:

>
> In some cases, you *want* to retain the same element between 
> loops, e.g., if you're iterating over elements of some category 
> and stop when you encounter something that belongs to the next 
> category -- you wouldn't want to consume that element, but 
> leave it to the next loop to consume it.  So it's not a good 
> idea to have break call .popFront automatically.  Similarly, 
> sometimes you might want to reuse an element (e.g., the loop 
> body detects a condition that warrants retrying).

I'm only talking about foreach() uses and that you should'nt need 
to mix it with manual methods. Such iterations are another topic.



More information about the Digitalmars-d-learn mailing list