Timeline for Why does C# type pattern matching use a different variable scoping behavior than traditional switch blocks?
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 15, 2019 at 15:02 | comment | added | Robert Harvey | Oh, please. ... | |
May 15, 2019 at 15:02 | comment | added | Ewan | MULIPLE RETURN POINTS FROM A FUNCTION!!!!!! splurts coffee over monitor monocle pops out | |
May 15, 2019 at 15:01 | comment | added | Robert Harvey |
As to the utility of switch , it becomes a lot nicer if you can return something from your cases.
|
|
May 15, 2019 at 14:57 | comment | added | Ewan | No. It will compile. The example just uses different names but the scoping is the same | |
May 15, 2019 at 14:56 | history | edited | Ewan | CC BY-SA 4.0 |
added 285 characters in body
|
May 15, 2019 at 14:55 | comment | added | Robert Harvey | Your "before" example uses two different variables. Are you saying that using the same variable name, as described in the OP, will not compile? | |
May 15, 2019 at 14:54 | comment | added | Ewan | its copied from the doc. ive added the before example | |
May 15, 2019 at 14:54 | history | edited | Ewan | CC BY-SA 4.0 |
added 285 characters in body
|
May 15, 2019 at 14:53 | comment | added | Robert Harvey | This is a bit different than the code the OP posted, which looks more like "polymorphic casting," of sorts. | |
May 15, 2019 at 14:52 | history | answered | Ewan | CC BY-SA 4.0 |