Remove switch case fallthrough
Paul Backus
snarwin at gmail.com
Fri May 21 19:41:36 UTC 2021
On Friday, 21 May 2021 at 19:25:22 UTC, Ogi wrote:
> On Friday, 14 May 2021 at 20:58:57 UTC, Dennis wrote:
>> ```D
>> void main() {
>> int x = 3;
>> string name = x switch {
>> 0 => "zero",
>> 1 => "one",
>> 2 => "two",
>> };
>> }
>> ```
>
> This particular example can be emulated with this template:
>
> ```D
> template mapSwitch(alias map)
> {
> ```
There's also [`std.algorithm.comparison.predSwitch`][1] in
Phobos, which does something similar.
[1]:
http://phobos.dpldocs.info/std.algorithm.comparison.predSwitch.html
More information about the Digitalmars-d
mailing list