Thread overview | |||||
---|---|---|---|---|---|
|
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? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | 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? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | 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 ;)
|
Copyright © 1999-2021 by the D Language Foundation