yeah it seems feels delibrately awkward to leave off the last
break...sorta like writing a one line if.



On 12/21/06, Andy Herrman <[EMAIL PROTECTED]> wrote:
Yea, the last break is unecessary, but I think it's a good idea to put
there.  Just to have the habit of already remembering to put breaks at
the end of case statements (I've forgotten a couple times and went
nuts looking for the bug).  And as Wagner mentioned, it protects
against people adding more cases to the end of the switch statement.

   -Andy

On 12/21/06, Wagner Amaral <[EMAIL PROTECTED]> wrote:
> The last break on default is considered by some to be a coding
> standard, by which you explicitly say you wanted to leave the default
> block empty, and not just simply forgot.
> Also, if unadvised people add code at the end of the switch without
> realizing the missing break, your default will fall-through.
>
>
>
> On 12/21/06, T. Michael Keesey <[EMAIL PROTECTED]> wrote:
> > On 12/21/06, Julien Vignali <[EMAIL PROTECTED]> wrote:
> > >
> > > switch(condition){
> > >   case A:
> > >   break;
> > >   case B:
> > >   break;
> > >   default:
> > >     // not mendatory but should always be the last statement
> > >   break;
> > > }
> >
> > That last break is actually unnecessary. The breaks are only to keep
> > it from going to the next case. In some (pretty rare) cases, you may
> > not even want to do that, e.g.:
> >
> > switch(a) {
> > case 0:
> >    // Does this if a == 0
> >   break;
> > case 1 :
> >    // Does this if a == 1.
> > case 2 :
> >    // Does this if a == 1 or a == 2.
> > default :
> >   // Does this if a is anything but 0.
> > }
> >
> > --
> > T. Michael Keesey
> > The Dinosauricon: http://dino.lm.com
> > Parry & Carney: http://parryandcarney.com
> > ISPN Forum: http://www.phylonames.org/forum/
> > _______________________________________________
> > [email protected]
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to