-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Update patterns.md with empty property pattern details #49385
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
Conversation
Clarify the behavior of the empty property pattern in C#.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds clarification about the behavior of the empty property pattern (is { }) in C#, which was previously undocumented in the patterns documentation.
Key Changes:
- Added a note explaining that the empty property pattern
is { }matches all non-null values and can be used as an alternative tois not nullfor creating variables.
|
I like this change. I think it would be more clear to readers if you added an example of |
|
hi @BillWagner i didn't know how the or do you mean just expanding the inline |
|
Adding a second file in the same PR isn't easy in the GitHub UI. If you add an inline example, I'll move it to the included snippets. |
Added a code example demonstrating the use of an empty property pattern with variable creation in C#.
|
is that sample something like what you were thinking of @BillWagner |
Per conversation on dotnet#49385
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Thanks @AdmiralSnyder I did pull your branch down, and put the sample in the correct snippet folder. I'll approve and merge once the build finishes. |
|
closing and reopening to try a new build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again @AdmiralSnyder
This LGTM, and I'll
now.
Clarify the behavior of the empty property pattern in C#.
Summary
added note about the empty property pattern because it wasn't mentioned anywhere.
Internal previews
isandswitchexpressions, and operatorsand,or, andnotin patterns