digitalmars.D - foreach order on arrays?
- Nick Sabalausky (5/5) Feb 25 2005 I thought I saw this mentioned somewhere before, but I can't seem to
- Manfred Nowak (7/15) Feb 25 2005
- Nick Sabalausky (2/22) Feb 25 2005 Oh, heheh. It's right there in the main docs ;)
I thought I saw this mentioned somewhere before, but I can't seem to find it now. When you use foreach to iterate over a static array or a dynamic array, is the sequence of iteration guaranteed to be [0], [1], ..., [length-2], [length-1]? If not, is there any particular guaranteed order?
Feb 25 2005
Nick Sabalausky <a a.a> wrote:I thought I saw this mentioned somewhere before, but I can't seem to find it now. When you use foreach to iterate over a static array or a dynamic array, is the sequence of iteration guaranteed to be [0], [1], ..., [length-2], [length-1]? If not, is there any particular guaranteed order?<cite href="http://www.digitalmars.com/d/statement.html#foreach"> If the aggregate expression is a static or dynamic array, the elements are iterated over starting at index 0 and continuing to the maximum of the array. </cite> -manfred
Feb 25 2005
Manfred Nowak wrote:Nick Sabalausky <a a.a> wrote:Oh, heheh. It's right there in the main docs ;)I thought I saw this mentioned somewhere before, but I can't seem to find it now. When you use foreach to iterate over a static array or a dynamic array, is the sequence of iteration guaranteed to be [0], [1], ..., [length-2], [length-1]? If not, is there any particular guaranteed order?<cite href="http://www.digitalmars.com/d/statement.html#foreach"> If the aggregate expression is a static or dynamic array, the elements are iterated over starting at index 0 and continuing to the maximum of the array. </cite> -manfred
Feb 25 2005