-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Proposal: Negative Pattern #16766
Labels
Comments
Very interesting. Can you give more examples, please. |
To clarify, this is just another "recursive pattern", once those are introduced to the language you can imagine more usages from combining various kinds of patterns. |
Recursive pattern should be just as it is |
Moved to dotnet/csharplang#246. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Moved from: #16742 (comment)
I propose to add a pattern operator to negate the effect of another pattern,
not-pattern:
not
patternA "negative pattern" could be applied to an arbitrary pattern and reverse the failure path.
Examples:
It could be even nested in recursive patterns as well,
This would be consistent with other proposed pattern operators like #6235.
Note that definitive assignment rules are reversed, for example,
This also eliminates the need to parenthesize the
is
expression in case you want to negate the result.The text was updated successfully, but these errors were encountered: