View mode: basic / threaded / horizontal-split · Log in · Help
February 25, 2005
foreach order on arrays?
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
Re: foreach order on arrays?
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
Re: foreach order on arrays?
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 ;)
Top | Discussion index | About this forum | D home