You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to make a short lambda _ for functions with 1 argument (like Scala, ..)
Now var result = list.map((x) => convert(x));
Possible var result = list.map(convert(_));
Most containers methods work with such lambdas and it would dramatically reduce syntax noise (garbage) in complex code.
The text was updated successfully, but these errors were encountered:
Claus1
changed the title
Short function declaration
Short lambda function declaration
Aug 4, 2019
It works but short lambda _ has a direct reference to the object and such code is possible var result = list.map(convert(_.field));
where the field is a field of argument.
or var result = list.flter(_ > 0 && _ < 100);
It is possible to make a short lambda _ for functions with 1 argument (like Scala, ..)
Now
var result = list.map((x) => convert(x));
Possible
var result = list.map(convert(_));
Most containers methods work with such lambdas and it would dramatically reduce syntax noise (garbage) in complex code.
The text was updated successfully, but these errors were encountered: