About foreach loops

so so at so.so
Wed Jun 15 08:34:08 PDT 2011


On Wed, 15 Jun 2011 18:23:55 +0300, Caligo <iteronvexor at gmail.com> wrote:

> This should be a compile time error:
>
>   foreach(i; 0..10){
>     i += 1;
>     write(i, " ");
>   }
>
> This should be legal.
>   foreach(ref i; 0..10){
>     i += 1;
>     write(i, " ");
>   }
>
> Is that the general consensus here?

They both should be legal, the first one is value, the second one is  
reference.


More information about the Digitalmars-d mailing list