Break exits the innermost flow control structure. In this case, break exits the if statement. Yes, break would be pointless in that statement. Return would not depending on what you're trying to do. I have no idea what you mean by that last line.
Haha,never mind,it was a stupid question.
Let me be sure that i got it,,return exit the function,but break get me out of the conditions and jumps to the code after it ,right ? :$
That's right. But in the case of breaks, it only breaks out of one control flow. If you had a loop in a loop, it only breaks out of the inner most loop.
break will exit from the innermost switch, for, do, or while block. Think of it as a goto the first statement after the block. It has nothing to do with if statements. It is an error to use break if not within a switch, for, do, or while block.
Comment