Default tuple argument #3002
Replies: 5 comments
-
👎 from me -- mixing tuple and anonymous object syntax looks really confusing. |
Beta Was this translation helpful? Give feedback.
-
If the primary goal is to have succinct syntax for calling the method, wouldn't a custom type combined with target-typed public struct Point
{
public float X, Y, Z;
public Point(float x = 0, float y = 0, float z = 0) => (X, Y, Z) = (x, y, z);
}
public void SetPoints(params Point[] points)
{
}
SetPoints(new(x: 1f), new(y: 1f), new(z: 1f)); The syntax to declare |
Beta Was this translation helpful? Give feedback.
-
@svick Because I think I shouldn't need to define a new type just for making a convenient method @canton7 As for me I just felt like it is implicit conversion between anonymous type and tuple |
Beta Was this translation helpful? Give feedback.
-
@Thaina There's no existing implicit conversion between an anonymous type and a tuple though? So you're adding a second new thing to the language, and I object to it. |
Beta Was this translation helpful? Give feedback.
-
That's not the point. I just try to draw a similarity that it could be felt like it was automatically processed as implicit conversion between tuple and anonymous type. Both of it is anonymous object and could be mapped by member's name. So it seemingly convertible. Nothing should felt confused |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Sometimes tuple argument can expect default value of some field and could be overridden
So I think it would be useful if API provider could
It just using syntax of anonymous object, but actually it would be transpiled into tuple
It should be able to specified default to only some member. And that member will be required
ps. I just use
params
as sample but actually I propose this to work with normal tuple argument tooBeta Was this translation helpful? Give feedback.
All reactions