4 ms·
> If a lambda has only one parameter then its declaration can be omitted (along with the ->). The name of the single parameter will be "it". > val notPositive
by brianwillis 9y ago
> If a lambda has only one parameter then its declaration can be omitted (along with the ->). The name of the single parameter will be "it".
> val notPositive = not {it > 0}
This idiom took me by surprise. It's really quite lovely, and now I'm disappointed C# doesn't include it.
- pvdebbe 9y agoThe schools for and against anaphoric syntax constructs are pretty divided 50-50. "It" is certainly better than scala's underscore.