break in a case with return.. and for default break in a case with return.. and for default c c

break in a case with return.. and for default


You don't need either break, but there's no harm in having them. In my opinion, keeping your code structured is worth having a couple of extraneous statements.


I agree with having a break in a final default case, and don't agree with breaks after returns. (A colleague does those and it hurts my eyes.)

I also indent switches so as to reduce proliferation of indent levels. :) i.e.:

switch(option) {case 1:    a = 1;    b = 7;    break;case 2:    a = 2;    b = 4;    return -1;default:    a = -1;    break;}

(I also think that, since the return statement is not a function, it isn't appropriate to enforce a superfluous style that makes it look like one.)


The break after your default case is just a matter of personal preference.

Putting a break after return almost seems contradictory to me. I'd remove the break, just to make the return statement really stand out.