61
cwizard
7y

Void foo() {
try {
//Try something
} catch(exception e) {
foo();
}
}

When I saw this in production I cried a little...

Comments
  • 4
    if I were you I might get a heart attack :\
  • 9
    Try until you suceed.
  • 6
    The code version of the definition of insanity.
  • 3
    @gitpush imagine it being working on that second call due to some other global variable. Now that would be a real brainfuck.
  • 5
    It is much beautiful like that

    void foo(int delay){
    try{
    //try something
    } catch(exception e) {
    wait(delay);
    foo(delay * 2);
    }
    }
  • 2
    @abhishekb that my friend is how you halt a computer T_T
  • 1
    I've done a similar thing on my arduino for wifi.

    Until it connects, it's of no use to run anything. Just try to connect to the given AP once again and again and again until you are connected
  • 0
    HERESY

    @ladiesman
  • 0
    var failed = false;
    do
    {
    try
    {
    // do something
    failed = false;
    } catch (Exception e)
    {
    failed = true;
    }
    }while(failed)

    There we go, now it’s just an infinite loop instead of a stack overflow. 🤣🤣
Add Comment