News for hackers. Stuff that matters.
Re:Those Who Say Code Does Not Matter by abshack on Wednesday April 16, 2014 @02:48PM (#7599705)

    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);

There are no comments on this comment yet.