What is the correct way of making this output `0 1 2`?
```d void delegate()[] dgs; foreach (immutable i; 0..3) { dgs ~= () => writeln(i); } foreach (dg; dgs) { dg(); // outputs: `2 2 2` } ```
Anonymouse via Digitalmars-d-learn Tue, 14 Jun 2022 01:31:07 -0700
What is the correct way of making this output `0 1 2`?
```d void delegate()[] dgs; foreach (immutable i; 0..3) { dgs ~= () => writeln(i); } foreach (dg; dgs) { dg(); // outputs: `2 2 2` } ```