Lambda syntax, etc

Kagamin spam at here.lot
Thu Feb 19 00:35:39 PST 2009


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; });

array.filter((x){x>3})
array.filter(x => x>3)
array.map(dep => dep.director)

I've run into one article. It points out that C# operator => can be viewed as convertion, so operations working with such convertions look rather natural and expressive.



More information about the Digitalmars-d mailing list