11

So I found these stack overflow questions and thought they were particularly humorous.

https://stackoverflow.com/questions...
https://stackoverflow.com/questions...

The answers were pretty good. But I wanted to actually "break out of an if statement" like the ops asked for. So I created these monstrosities:

Comments
  • 6
    10/10 for readability and implementation

    I will personally ensure your approach will become the industry standard and implement this work of art across all our projects!

    for(bool run=true; run; run=false){

    if(!userAuthorized()){

    //show auth page

    break;

    }

    //do something that requires user authorization

    }

    I love it
  • 3
    😂

    I love that most languages allow you to do absolutely crazy things like this.
  • 1
    Making it a switch with only a default case is nicer
  • 1
    @electrineer I thought about that after. lol
  • 0
    Why not just invert a condition and put the logic inside 'if' instead?
  • 3
    @iiii Because @Demolishun isn’t trying to do something sane.
Add Comment