Hello,

I have some piece of code that compiles and runs fine:

void main(string[] args)
{       
        int a = 7;
        int delegate() dg = { return a + 3; };
        auto result = dg();
        writeln(result);
}

Now I want the closure (aka delegate) to have a closure variable:

int a = 7;
int delegate(int) dg = { value => return value + a + 3; };
auto result = dg(123);

Unhappily, the code above doesn't compile. Tried various things, looked for samples on the D hompepage and in the book by Çehreli, but had no luck.

Some hints appreciated.
Thanks, Bienlein

Reply via email to