As known this code will not work as we may expect:
import std.stdio;
void main(string[] args)
{
void delegate ()[] delegates;
foreach(i; 0..10) {
int j = i;
delegates ~= delegate() {
writeln(j);
};
}
foreach(dlgt; delegates) {
dlgt();
FreeSlave wrote:
As known this code will not work as we may expect:
import std.stdio;
void main(string[] args)
{
void delegate ()[] delegates;
foreach(i; 0..10) {
int j = i;
delegates ~= delegate() {
writeln(j);
};
}
foreach(dlgt; del
On 02.06.2017 16:03, FreeSlave wrote:
As known this code will not work as we may expect:
import std.stdio;
void main(string[] args)
{
void delegate ()[] delegates;
foreach(i; 0..10) {
int j = i;
delegates ~= delegate() {
writeln(j);
};
}