On Tuesday, 3 June 2014 at 07:00:35 UTC, Ali Çehreli wrote:
Here is a workaround:

unittest {
    size_t delegate()[size_t] events;

    auto makeClosure(size_t i) {
        return { return i; };
    }

    foreach( i; 1..4 ) {
        events[i] = makeClosure(i);
    }

    assert( events[1]() == 1 );
}

void main()
{}

Ali

Thank you Ali, that works beautifully and can be easily adapted to the original (more complicated) case.

Cheers, Edwin

Reply via email to