Improvements to switch

ryuukk_ ryuukk.dev at gmail.com
Tue Apr 16 10:34:21 UTC 2024


It is time to make them nice to use


- allow them as expression

```D
int myvalue = switch(code) {
     // ...
};

```

- more concise

```D
switch(code) {
     case 1 -> "what";
     case 2, 3 -> "ok";
     else -> "no";
}
```

- pattern match

```D
switch(tagged) {
     case A, B -> do_that();
     case C myc -> do_this(myc);
     else -> nothing();
}
```


More information about the dip.ideas mailing list