About foreach loops
so
so at so.so
Wed Jun 15 09:25:51 PDT 2011
On Wed, 15 Jun 2011 19:08:29 +0300, Caligo <iteronvexor at gmail.com> wrote:
> A reference to what exactly?
>
> Does this make any sense:
> for(ref int i; i < 10; ++i){
> i += 1;
> write(i, " ");
> }
>
> It doesn't even compile.
It is same as the other argument, the element, it should work the same way.
> 'foreach(i, 0..10){ }' is syntactic sugar for 'for(int i = 0; i < 10;
> ++i){ }', is it not?
We don't know, and we don't need to know. It might be a wrapper over
"while" too, since its a different entity it might have its own rules. And
having element and the element index share same rules would be both
consistent and the right thing to do.
More information about the Digitalmars-d
mailing list