Backtrack:  
 
by lunarg on May 28th 2015, at 11:39

For debugging purposes, I often prematurely abort a function by adding a return statement in the middle of it. With most compilers this works flawlessly, accept with Java...

The Java compiler bums out with an unreachable statement error, and won't allow you to compile a class until all code is reachable within a function.

Luckily, you can trick the compiler by adding an if-statement that's always true:

if (1==1) return;

This way, as the return is supposedly conditional, and the compiler doesn't consider the result of an if-statement, it is tricked into believing the following code is still reachable.

 
 
« March 2025»
SunMonTueWedThuFriSat
      1
2345678
9101112131415
16171819202122
23242526272829
3031     
 
Links
 
Quote
« You only find out who is swimming naked when the tide goes out. »
Warren Buffett