Sergey Gromov wrote:
Sun, 18 Jan 2009 07:21:55 -0800, Andrei Alexandrescu wrote:

http://www.digitalmars.com/d/2.0/statement.html#ForeachStatement

Scroll down to "Foreach over Structs and Classes with Ranges". The changelog reflects that too:

How do I implement a range that supports more than one pass?  From the
docs, all ranges seem to be essentially Input ranges currently.  That is

MyIterable collection;
foreach (element; collection) {} // OK, iterates
foreach (element; collection) {} // oops, it's empty!

Note that the range is being copied into a hidden variable, so after the first iteration the collection will still hold its ground.

Andrei

Reply via email to