3 ms·
> I got this a little but not a lot wrong. return 42 is supported but then it isn't clear at all why 42 is necessary. The reason this is very good is closures,
by tatterdemalion 10y ago
> I got this a little but not a lot wrong. return 42 is supported but then it isn't clear at all why 42 is necessary.
The reason this is very good is closures, which have the same return semantics as functions, are often a single expression, and are most useful to fit on one line. `.filter(|x| x.foo_bar() < some_other.foo_bar())`. Removing the return statement helps here.
Its a behavior shared with many (but not all) languages that make heavy use of anonymous functions.
- fjrieiekd 10y agoSwift does support this also, but they limited it so they could also get rid of semicolons entirely.