blocks with attributes vs inlined lambda
monarch_dodra
monarchdodra at gmail.com
Sat Jun 8 10:27:47 PDT 2013
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
}
-------
More information about the Digitalmars-d
mailing list