Pattern variables #4776
Unanswered
kyoyama-kazusa
asked this question in
Language Ideas
Replies: 3 comments 5 replies
-
When you answer things later at night, sometimes you misread. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Does #4131 address your question? |
Beta Was this translation helpful? Give feedback.
1 reply
-
I would have syntax like public static class MyClass
{
pattern int Positive > 0;
pattern int Even % 2 == 0;
pattern Complex Real { RealPart: > 0 };
} example similar to what the OP posted: if (c is Real re) ...
if (a is Even) ...
if (student is { Attitude: Positive }) ... (the patterns will be colored differently from types by IDEs to make it clear) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
Can we extract a pattern into a variable to store, and then use it multiple times? Such as:
Beta Was this translation helpful? Give feedback.
All reactions