Is using the break statement bad practice?
Posted
by Lchi
on Stack Overflow
See other posts from Stack Overflow
or by Lchi
Published on 2010-04-17T03:27:30Z
Indexed on
2010/04/17
3:33 UTC
Read the original article
Hit count: 276
I've been told by professors and peers at my university that using the break statement is bad practice, but through my coursework haven't come up with a great reason why. Those who claim that it is bad say that it's a "get out of jail free card" and that you can always avoid using it.
My guesses for why its considered bad would be that you could possibly skip some cleanup code after the break, or similarly exit some control structure in an inconsistent state.
Is there any reason why using break is(n't) bad practice?
© Stack Overflow or respective owner