3 ms·
Not sure if I like primary constructors. TBH, the following feature of Dart that I like: class Point { public Point(this x, this y); int x; int y
by genter 3y ago
Not sure if I like primary constructors. TBH, the following feature of Dart that I like:
class Point {
public Point(this x, this y);
int x;
int y
}
Everything else seems like small quality of life improvements.
And still patiently waiting for the following to be legal:
int result = some_variable switch { a => callAFunctionReturningVoid(); 1, b => 2, };
- yread 3y agothis parameters (well the first one) is already used for extension methods. Constructors can't be extension methods but it could still lead to confusion
- genter 3y agoNever realized that, but yes. Seems like it would be better to have a different syntax for extension methods, I always thought they were clunky, but too late now.
- zigzag312 3y agoI don't know, if Dart is a good example. Dart constructors are really limited.
- jve 3y ago> int result = some_variable switch { a => callAFunctionReturningVoid(); 1, b => 2, }; What does it even mean? Multi-statement lambdas without return statement, I get it, but what is the return value? And returning a void to int? How is it all supposed to work? What the trailing comma means? Inconsistent way of dealing with things that may confuse developers just results in that proposal resisted.
- bng5 3y agoIt is not a lambda but a switch expression. The tricky bits here are separating a call and the returned expression with ;. The trailing comma is just sugar to allow for another case
- jve 3y agoUnderstood. You want to escape curly braces and let the last expression be the returned one. F# does implicitly return the last expression. > The expression is the body of the function, the last expression of which generates a return value. Examples of valid lambda expressions include the following: https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/lambda-expressions-the-fun-keyword#remarks https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...
- vsareto 3y agoJust IMO but that line does too much and deserves a regular switch due to the function call. It's too compressed for readability.