foreach(ubyte j;0 .. num) is bugging out
jfondren
julian.fondren at gmail.com
Thu Sep 23 00:36:01 UTC 2021
On Thursday, 23 September 2021 at 00:30:45 UTC, Ruby The Roobster
wrote:
> I figured out something weird. The variable 'i' is passed by
> reference, yet the variable 'i' of the loop isn't being
> incremented by posfunc. I assume foreach creates a new i
> variable at the start of each new loop.
Yep:
```
$ rdmd --eval 'foreach (i; 0 .. 5) { writeln(i); i++; }'
0
1
2
3
4
```
More information about the Digitalmars-d-learn
mailing list