Does a "return..." statement make a "break;" moot?

Reading your ideas about switch and return, yes, a return statement can be considered as a specialized break statement.

A break is just a branch table abstraction, so as return is, so at the end of the day, they will simply execute a jump instruction.


There is no magic behind the scene. The only big difference here is that with break you only leave the switch with return the function. So the consequences are obvious. If you have return you do not need a break as the break will never be reached. Some IDE will it grey out to point you out it is not reachable fragment of code.


No a return statement is not a specialised break. return causes you to exit the function break causes you to exit the switch statement. You don't need the break if you have the return, but they are different things.