Local variable inside delegate literal
Daniel
yebbliesnospam at gmail.com
Tue Dec 22 23:47:32 PST 2009
I'm writing some gui code, and am currently trying to make something equivalent to this:
int delegate()[] funcs;
funcs.length = 3;
foreach(i, ref f; funcs)
{
f = int() { return i; }
}
foreach(f; funcs)
{
writeln(f());
}
Prints:
3
3
3
I want it to print
0
1
2
Is there anyway to get this behaviour using delegate literals initialized with a runtime loop?
More information about the Digitalmars-d
mailing list