Sugaring the switch()

Dean Edwards dean at edwards.name
Sat Sep 6 04:45:27 PDT 2008


Michael Haufe wrote:
> I didn't see this mentioned yet, so I'd like to propose implementing a 
> feature available in VB.NET that I think would be valuable in ES. Some 
> sugar for the switch() block:
> 
> switch(foo){
>     case 1,2,3:
>         //stuff...
>     break;
>     case a,b,c:
>         //stuff...
>     break;
> }
> 

Same as:

switch(foo){
     case 1:
     case 2:
     case 3:
         //stuff...
     break;
     case a:
     case b:
     case c:
         //stuff...
     break;
}

-dean


More information about the Es-discuss mailing list