'in' for arrays?

Lionello Lunesu lio at lunesu.remove.com
Wed Dec 6 05:36:45 PST 2006


Alexander Panek wrote:
> Lionello Lunesu wrote:
>> switch(val) {
>>   case "off","disable","no":
>>      // code here
>>   default:
>>      break;
>> }
> May I ask in what way this is different from:
> 
> switch ( val ) {
>     case "off":
>     case "disable":
>     case "no":
>         // code here
>         break;
> }

case x,y: is the same as case x: case y:
Apart from that, if you don't provide a 'default' statement, D inserts 
one with assert(0), meaning that your code would trip if val were 
anything other than those 3 mentioned cases.

L.



More information about the Digitalmars-d mailing list