On Saturday, 13 March 2021 at 21:33:20 UTC, Meta wrote:
On Saturday, 13 March 2021 at 21:15:40 UTC, Martin Nowak wrote:
[...]
Allow shortened function implementations for single-expresssion
functions.
-preview=shortenedMethods is added. This allows functions to be
written in a similar form to lambda functions:
// these 2 are equivalent
int foo() { return 1; }
int foo() => 1;
The syntax allows the form => expr to replace the function body
{ return expr; }
Amazing! I had no idea this got in. I love the syntax.
It's pretty neat, but a DIP has to be drafted and approved for it
to be enabled by default, right? (Unless I missed it.)