by abshack · 12y ago · 0 comments
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);No comments yet.