Nick Sabalausky:
It seems that foreach is iterating over an implicit copy of 'foo' instead of'foo' itself. Is this correct behavior, or a DMD bug?
This program prints "[11, 21, 31]" so for fixed-size arrays (that
are values as much as structs) it doesn't perform a copy:
import std.stdio;
void main() {
int[3] a = [10, 20, 30];
foreach (ref x; a)
x++;
writeln(a);
}
Bye,
bearophile
