'in' for arrays?

Alexander Panek a.panek at brainsware.org
Wed Dec 6 05:50:40 PST 2006


Lionello Lunesu wrote:
> 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.

Yea..I've seen that I forgot the default: break; after replying.. :P



More information about the Digitalmars-d mailing list