On Tue, 05 Feb 2013 23:17:59 -0500, Steven Schveighoffer <[email protected]> wrote:

e.g.:

import std.stdio;

void callit(void delegate() dg)
{
     // call delegate with context pointer
     dg();
}

void main()
{
     int x;
auto dg = ()=>writeln(++x); // create a delegate using a lambda function
     callit(dg);
     callit(dg);
     callit(dg);
     callit(dg);
}

Forgot to say, the output here would be:

1
2
3
4

-Steve

Reply via email to