-
As far as I can see currently specification allows any to be pattern used in
But for example using declaration pattern in case of multiple labels does not make much sense (as far as I understand) since the variable can't be used due to unassigned variable (for obvious reasons):
P.S. Seems to be pretty "edge-caseish" and probably not worth the effort. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I forget the name of the proposal (can look it up later) but there is one for allowing overlap of the pattern variables between disjunctive patterns that would allow something like this: switch (obj) {
case Person(string name):
case Business(string name):
// can use name here, it's definitely assigned by one of the two patterns
break;
} And while those variables aren't definitely assigned, they could be within the switch block and then they could be used. |
Beta Was this translation helpful? Give feedback.
I forget the name of the proposal (can look it up later) but there is one for allowing overlap of the pattern variables between disjunctive patterns that would allow something like this:
And while those variables aren't definitely assigned, they could be within the switch block and then they could be used.