On Saturday, 8 June 2013 at 16:21:26 UTC, deadalnix wrote:

{} is a lambda already. The first set of () is optional.

Oh Yeah. Didn't know that. You learn something new every day.

...but for that to work, (it seems) you have actually store or pass the lambda, or all the parser sees is a plain "block".

-------
void main()
{
    int i;
    auto y = {++i;}; //lambde (not called)
    {++i;};          //simple block
    (){++i;}();      //inline lambda call
    writeln(i); //prints 2
}
-------

Reply via email to