About switch case statements...

Max Samukha spambox at d-coding.com
Mon Nov 16 02:16:01 PST 2009


On Sun, 15 Nov 2009 15:03:39 -0600, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:

>Walter Bright wrote:
>> Don wrote:
>>> And looking at how rarely it's actually used by someone who thinks he 
>>> uses it a lot, convinces me that intentional use of fall-through is 
>>> much less common than bugs introduced by leaving out a break statement.
>> 
>> Except that I cannot recall ever having a bug from leaving out a break <g>.
>
>I can. I'm not sure where that leaves us. Others - please add your 
>experience.
>
>Andrei

I used to introduce bugs by leaving out 'break'. So I had to fall into
habit of writing 'break' before adding other code to a case block.
Fall-through should be explicit.



More information about the Digitalmars-d mailing list