Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

The goto-less goto!

By , 31 Jan 2011
Rate this:
Please Sign up or sign in to vote.
It is much easier (and cleaner) to test for success than to test for failure.

if (  condition1   // Note: Test for success, not for fail
   && condition2   // Will be short-circuited if condition1 fails
   && condition3   // Will be short-circuited if condition1 or condition 2 fails
   && conditionn
}  // if


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author


United Kingdom United Kingdom
No Biography provided

Comments and Discussions

GeneralFor me is one of the simplests aproaches. 5 for you. PinmemberJose David Pujo31-Mar-11 21:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 31 Jan 2011
Article Copyright 2011 by jsc42
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid