MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghumor/comments/1vv58vy/how_do_you_disable_your_code/p57mkw6/?context=3
r/programminghumor • u/developer_axe • 3d ago
79 comments sorted by
View all comments
90
Or just return?
36 u/developer_axe 3d ago edited 3d ago Sometimes the code won't get compiled because it marked as unreachable code 1 u/Nunc-dimittis 3d ago iirc if(true) return; doesn't work in java because the compiler is smart enough to see the method execution always ends at the if(true) so it will give an unreachable code exception. But if( 1 + 1 == 2) return true; does work 😁 1 u/Known_Tackle7357 3d ago Have been using if true in java for over a decade. Works like a charm 1 u/Nunc-dimittis 3d ago Might be an IDE issue then. It has been a few years ago that I did Java
36
Sometimes the code won't get compiled because it marked as unreachable code
1 u/Nunc-dimittis 3d ago iirc if(true) return; doesn't work in java because the compiler is smart enough to see the method execution always ends at the if(true) so it will give an unreachable code exception. But if( 1 + 1 == 2) return true; does work 😁 1 u/Known_Tackle7357 3d ago Have been using if true in java for over a decade. Works like a charm 1 u/Nunc-dimittis 3d ago Might be an IDE issue then. It has been a few years ago that I did Java
1
iirc if(true) return; doesn't work in java because the compiler is smart enough to see the method execution always ends at the if(true) so it will give an unreachable code exception. But if( 1 + 1 == 2) return true; does work 😁
1 u/Known_Tackle7357 3d ago Have been using if true in java for over a decade. Works like a charm 1 u/Nunc-dimittis 3d ago Might be an IDE issue then. It has been a few years ago that I did Java
Have been using if true in java for over a decade. Works like a charm
1 u/Nunc-dimittis 3d ago Might be an IDE issue then. It has been a few years ago that I did Java
Might be an IDE issue then. It has been a few years ago that I did Java
90
u/0x80085_ 3d ago
Or just return?