Remove switch case fallthrough

Dennis dkorpel at gmail.com
Fri May 14 20:58:57 UTC 2021


On Friday, 14 May 2021 at 19:39:09 UTC, Ogi wrote:
> But it seems we are in a minority here. Named arguments and 
> string interpolation are far more popular and important 
> features but we are still waiting for them.

I actually suspect there's a non-vocal group of D users 
dissatisfied with the old switch, though I don't think there's 
consensus on what the new switch would look like.

Personally, I think [C#'s switch 
expressions](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/switch-expression) look appealing, and they are compatible with D's syntax. Here's what the basic form looks like:

```D
void main() {
     int x = 3;
     string name = x switch {
         0 => "zero",
         1 => "one",
         2 => "two",
     };
}
```
Examples with pattern-matching and case guards can be found in 
the link.



More information about the Digitalmars-d mailing list