lijie:

import std.stdio;
void main() {
    void delegate()[] functions;
    foreach (i; 0 .. 5) {
        functions ~= {
            printf("%d\n", i);
        };

    }
    foreach (func; functions) {
        func();
    }
}


import std.stdio;

void main() {
    void delegate()[] functions;

    foreach (i; 0 .. 5)
        functions ~= ((int j) => { printf("%d\n", j); })(i);

    foreach (func; functions)
        func();
}

Bye,
bearophile

Reply via email to