digitalmars.D.learn - Reset Range
I have never interested in "Range" topic till now, but with Walter's presentation, I took a look at it today. Ali has a nice lesson page about it (http://ddili.org/ders/d.en/ranges.html). What I don't get is the mechanism to reset a range. I mean, you use a range with foreach, but then it is totally consumed. I cannot use it again. Because it will be empty. No special property function is defined for this. Maybe the reason I don't understand it is that it doesn't fit to my needs.
May 30 2015
On Saturday, 30 May 2015 at 08:36:02 UTC, tcak wrote:I have never interested in "Range" topic till now, but with Walter's presentation, I took a look at it today. Ali has a nice lesson page about it (http://ddili.org/ders/d.en/ranges.html). What I don't get is the mechanism to reset a range. I mean, you use a range with foreach, but then it is totally consumed. I cannot use it again. Because it will be empty. No special property function is defined for this. Maybe the reason I don't understand it is that it doesn't fit to my needs.You take a copy of the range prior to iteration with the 'save' method (which all forward ranges have: http://dlang.org/phobos/std_range_primitives.html#isForwardRange) if you need to reuse it.
May 30 2015