[Proposal]: Allow pattern matching to assign to new variable in more cases #7945
Unanswered
OJacot-Descombes
asked this question in
Language Ideas
Replies: 2 comments 4 replies
-
Note that in all of these cases, you can just append |
Beta Was this translation helpful? Give feedback.
3 replies
-
These examples look a bit strange to me, it's not as easy to read.
This would be great though. |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
Given the declaration
we can write
This tests the property
P
for being not null and assigns its value to the new variables
if the result istrue
. This is not very readable. It would be more readable if we could write:There are also other cases where assigning a new variable would be handy:
Proposal: allow pattern matching to test an expression and conditionally declare a new variable to the result of that expression in more cases.
Beta Was this translation helpful? Give feedback.
All reactions