Thread overview
foreach order on arrays?
Feb 25, 2005
Nick Sabalausky
Feb 26, 2005
Manfred Nowak
Feb 26, 2005
Nick Sabalausky
February 25, 2005
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?
February 26, 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
February 26, 2005
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 ;)