foreach () processing sequence
Johan Granberg
lijat.meREM at OVE.gmail.com
Tue Feb 6 12:40:50 PST 2007
jicman wrote:
> == Quote from Kirk McDonald's article
>> jicman wrote:
>> > Greetings!
>> >
>> > Imagine this declarion,
>> >
>> > char[] str = ["bb", "cc", "aa", "00", "11", "zz", "dd"];
>> >
>> > when I do a,
>> >
>> > foreach (char[] s; str)
>> > writefln(s);
>> >
>> > assuming that the str array has not been touched or altered in
> any
>> > way, will the sequence of execution **ALWAYS** follow the
> sequence
>> > of the array creation? In other words, will the execution of the
>> > foreach above always display,
>> >
>> > bb
>> > cc
>> > aa
>> > 00
>> > 11
>> > zz
>> > dd
>> >
>> > Thanks,
>> >
>> > jos�
>> (Nitpick: The type of str is char[][].)
>> Yes. An array is an ordered sequence. (As opposed to, say, a hash
> table,
>> which is unordered.)
>
> You're not nitpick, but acurate. :-)
>
> Ok, thanks.
I have wondered the same in the past. Is it documented somewhere? otherwise
I think it should be.
More information about the Digitalmars-d-learn
mailing list