'in' for arrays?

Alexander Panek a.panek at brainsware.org
Wed Dec 6 22:41:28 PST 2006


Hasan Aljudy wrote:
> 
> 
> Alexander Panek wrote:
>> 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
> 
> And you're very likely to forget it when writing code ..

I usually don't forget it..actually. But that's just me. ;)
(In this case lack of time prevented any re-reading :O )



More information about the Digitalmars-d mailing list