dcollections 1.0 and 2.0a beta released
bearophile
bearophileHUGS at lycos.com
Sat May 22 04:00:18 PDT 2010
Pelle:
> It's not a very good rule anyway:
>
> void inc_all(int[] xs) {
> foreach (ref x; xs) {
> x += 1;
> }
> }
>
> Wouldn't gain anything from ref, and wouldn't work with const.
You are wrong, it works correctly with ref:
import std.stdio: writeln;
void inc_all(ref int[] array) {
foreach (ref x; array)
x++;
}
void main() {
auto a = new int[10];
a.inc_all();
writeln(a);
}
It prints 1 1 1 1 1 1 1 1 1 1
Bye,
bearophile
More information about the Digitalmars-d-announce
mailing list