switch3

enum switch3 (
string pred
string action1
string action2
string action3
)

Examples

int func(bool val)
{
    mixin (switch3!("val", "return 1;", "return 2;", "return 3;"));
}

assert (func(true) == 3);
assert (func(false) == 3);

int func2(bool val)()
{
    mixin (switch3!("val", "return 1;", "return 2;", "return 3;"));
}

assert (func2!true == 1);
assert (func2!false == 2);

Meta