Skip to content
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

Type and Deconstruction Simultaneously #42307

Closed
zms9110750 opened this issue Aug 23, 2024 · 6 comments · Fixed by #42514
Closed

Type and Deconstruction Simultaneously #42307

zms9110750 opened this issue Aug 23, 2024 · 6 comments · Fixed by #42514
Assignees
Labels
dotnet-csharp/svc in-pr This issue will be closed (fixed) by an active pull request. lang-reference/subsvc needs-more-info Needs more info from OP. Auto-closed after 2 weeks if no response. [org][resolution] 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@zms9110750
Copy link

zms9110750 commented Aug 23, 2024

Type of issue

Missing information

Description

I found a usage method that did not appear in the document.

public abstract record Result<T> : IDisposable
{
	public sealed record Ok(T Value) : Result<T>;

	//...

	public T GetValueOrDefault()
	{
		switch (this)
		{
			case Ok(T Value):
				return Value;
		}
		return default(T)!;
	}
//...
}

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/patterns

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/operators/patterns.md

Document Version Independent Id

312e9c81-ee2a-1d84-64d7-bcaa71d7eab8

Article author

@BillWagner

Metadata

  • ID: 9112c305-f1cd-1aa5-4557-2c7d757e6ca0
  • Service: dotnet-csharp
  • Sub-service: lang-reference

Associated WorkItem - 310181

@BillWagner
Copy link
Member

Hi @zms9110750

Can you add an example where this is useful? I find the code interesting, but I'm not seeing a scenario where I'd use it in practice.

@BillWagner BillWagner added the needs-more-info Needs more info from OP. Auto-closed after 2 weeks if no response. [org][resolution] label Aug 23, 2024
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label Aug 23, 2024
@zms9110750
Copy link
Author

zms9110750 commented Aug 23, 2024

你好@zms9110750

您能添加一个有用的例子吗?我发现代码很有趣,但我没有看到在实践中使用它的场景。

I just saw this grammar here
I didn't realize this grammar until then, and the document didn't introduce it. So I think he should be supplemented.
I don't know the usage scenarios in practice, so I can't answer you.

@zms9110750
Copy link
Author

If the positional pattern relies entirely on Deconstruct, I think it would be better to directly change the title to Deconstruct pattern.

Copy link
Contributor

This issue has been automatically closed due to no response from the original author. Feel free to reopen it if you have more information that can help us investigate the issue further.

@zms9110750
Copy link
Author

@BillWagner hi?

@dotnet-policy-service dotnet-policy-service bot added the in-pr This issue will be closed (fixed) by an active pull request. label Sep 9, 2024
@BillWagner
Copy link
Member

Hi @zms9110750

Thanks for tagging me in that comment. I missed the earlier once, and it looks like one of our bots didn't restore labels correctly on your last comment.

I see your point. I'm not going to change the name. We chose that to match the name used in the specification. However, I did add a callout on the importance of order.

@BillWagner BillWagner reopened this Sep 9, 2024
@BillWagner BillWagner self-assigned this Sep 9, 2024
@BillWagner BillWagner added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label Sep 9, 2024
@BillWagner BillWagner moved this from 🔖 Ready to 👀 In review in dotnet/docs September 2024 Sprint Sep 9, 2024
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in dotnet/docs September 2024 Sprint Sep 9, 2024
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in dotnet/docs September 2024 Sprint Sep 9, 2024
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-csharp/svc in-pr This issue will be closed (fixed) by an active pull request. lang-reference/subsvc needs-more-info Needs more info from OP. Auto-closed after 2 weeks if no response. [org][resolution] 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants