[Proposal]: simplify testing multiple equality with in comparison #4065
Answered
by
svick
softlion
asked this question in
Language Ideas
-
In comparison
SummaryThis code: IsRotating = args.Status == GestureStatus.Started || args.Status == GestureStatus.Running could be simplified to: IsRotating = args.Status in [GestureStatus.Started, GestureStatus.Running] like in the SQL language. MotivationCleaner code with all the benefits by stopping repeating the equality comparison and the first argument to this comparison. Detailed designThis could be expanded by the compiler into the original syntax. Drawbacks"in" is a new keyword there. But it should not impact the existing syntaxes. AlternativesNone ? Unresolved questionsIn this the correct keyword to use ? Design meetings |
Beta Was this translation helpful? Give feedback.
Answered by
svick
Oct 25, 2020
Replies: 1 comment 3 replies
-
C# 9.0 includes IsRotating = args.Status is GestureStatus.Started or GestureStatus.Running; Is that sufficient for your needs? |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
YairHalberstadt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
C# 9.0 includes
or
patterns, which allow you to write code like the following:Is that sufficient for your needs?