Hacker News new | past | comments | ask | show | jobs | submit login

    if( DoSomething() )
        goto fail;
    else if(DoSomethingElse())
        goto fail;
        goto fail;
    else if(DoSomethingOtherThanElse())
        goto fail;
You get a syntax error at the final else-if. A better way would probably be:

    int err = 0;
    if(!err)
        err = DoSomething();
    if(!err)
        err = DoSomethingElse();
    if(!err)
        err = DoSomethingOtherThanElse();

    if(err) goto fail;
    
I would prefer chainable commands that abstracts out the error checking though.

    err = Chain(DoSomething).Then(DoSomethingElse).Then(DoSomethingOtherThanElse);



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: