On 02/03/2016 10:09 AM, ZombineDev wrote: > I think these two links, more or less, answer my question:> http://stackoverflow.com/questions/29759419/closures-in-loops-capturing-by-reference
> > https://issues.dlang.org/show_bug.cgi?id=2043
I find it more readable to give a name like makeClosure():
foreach (i; 0 .. 10) {
auto makeClosure = (int a) {
return { write(a, " "); };
};
arr ~= makeClosure(i);
}
Of course, makeClosure() can be moved out of the loop if needed.
Ali
