(St)Range behavior

Chris wendlec at tcd.ie
Fri Oct 25 04:06:14 PDT 2013


I have three lazy ranges tied together in a foreach loop like so:

Item[] items; // An array of Item-struct

foreach (item; items.range1.range2.range3) {
   // ...
}

The funny thing is that when I run the foreach loop it does 
everything in reverse. So I changed it to

foreach (item; items.range3.range2.range1) {
   // ...
}

And now it works as expected. I've never had such strange 
behavior and have no clue what could have caused it. In all my 
other ranges it works from left to right 1. step, 2. step, 3. 
step and not from right to left.


More information about the Digitalmars-d mailing list