May 21, 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:

>
void main() {
    int x = 3;
    string name = x switch {
        0 => "zero",
        1 => "one",
        2 => "two",
    };
}

This particular example can be emulated with this template:

template mapSwitch(alias map)
{

There's also std.algorithm.comparison.predSwitch in Phobos, which does something similar.

1 2 3 4 5
Next ›   Last »