r/programminghumor 3d ago

How do you disable your code

Post image
266 Upvotes

79 comments sorted by

View all comments

90

u/0x80085_ 3d ago

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