DIP32: Uniform tuple syntax

bearophile bearophileHUGS at lycos.com
Fri Mar 29 08:40:39 PDT 2013


Timon Gehr:

> Another thing, what do you do if there are multiple matching 
> patterns in a switch?:
>
> final switch({1,2}){
>     case {1,y}: ...; break;
>     case {x,2}: ...; break;
>     default: ...; break;
> }

You can't have "default:" in a final switch. The cases must be 
exhaustive of all possibilities:

final switch({1, 2}) {
     case { 1,  y}: ...; break;
     case { x,  2}: ...; break;
     case {$_, $_}: ...; break;
}


Bye,
bearophile


More information about the Digitalmars-d mailing list