Lambda syntax, etc
Denis Koroskin
2korden at gmail.com
Mon Feb 9 02:38:41 PST 2009
On Mon, 09 Feb 2009 13:24:46 +0300, Kagamin <spam at here.lot> wrote:
> Denis Koroskin Wrote:
>
>> Could be used as follows:
>>
>> foo( (i) { ++i; } );
>
> Holy shi-
> Now feel some real power, Luke. :)
>
> foo( i => ++i );
>
>> foo((i){ ++i; }); // error
>> foo((i){ ++i; return;}); // unambiguous
>> foo((i){ return ++i;}); // unambiguous
That was just an example. Those short lambdas are often used as predicates. Compare:
findAll(array, (i) { i > 3; });
findAll(array, (int i) { return i > 3; });
More information about the Digitalmars-d
mailing list