4 ms·
> Why drop curly braces? What do you mean? It uses curly braces for compound statements. But it doesn't require curly braces to define a one-line function.
by DerekL 4y ago
> Why drop curly braces?
What do you mean? It uses curly braces for compound statements. But it doesn't require curly braces to define a one-line function.
- 01100011 4y agoYeah, that just strikes me as weird.
- int_19h 4y agoIt makes it more consistent with statements, and more convenient for one-liner functions (e.g. those that just delegate to another function). It's also something that was adopted by other languages in the curly braces family - e.g. C# originally required curly braces for function bodies, but now allows you to write: int Sum(int x, int y) => x + y;