www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - foreach order on arrays?

reply Nick Sabalausky <a a.a> writes:
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
parent reply Manfred Nowak <svv1999 hotmail.com> writes:
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
parent Nick Sabalausky <a a.a> writes:
Manfred Nowak wrote:
 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
Oh, heheh. It's right there in the main docs ;)
Feb 25 2005