-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Champion: allow 'default' in deconstruction #1394
Comments
This will be super nice to do in constructors: class MyClass
{
int foo;
string bar;
byte baz
public MyClass() => (foo, bar, baz) = default;
} |
@AustinBryan Those fields are already zero-inited, so what is the purpose of that constructor? |
The use case I had in mind for this is assigning a bunch of out parameters on a failure case, bool TryGet(out int i, out double d) {
// ...
(i, d) = default;
return false;
} btw I think this is already implemented by jcouv, why the Any Time milestone? |
The implementation I have is not quite complete because we've recently implemented more target-typing scenarios (switch expressions in particular). So |
Taking some time into the code regarding this case, and a side-effect would have to also be matching the individual types of the tuple expression: (1, default)
(default, "")
(1, null) should match as
should match as I'm awaiting for a response on whether it's okay to follow this approach in another branch targeting the |
Closing as duplicate of #1358 |
Allow
(int i, string s) = default;
and(i, s) = default
.Initially raised in #1358 (thanks @KnorxThieus)
Prototype in decon-default branch
The text was updated successfully, but these errors were encountered: