Best way to format if statement with multiple conditions.
Posted
by Matt690
on Stack Overflow
See other posts from Stack Overflow
or by Matt690
Published on 2008-10-31T10:15:17Z
Indexed on
2010/06/14
4:42 UTC
Read the original article
Hit count: 203
If you want to some code to execute based on two or more conditions which is the best way to format that if statement ?
first example:-
if(ConditionOne && ConditionTwo && ConditionThree)
{
Code to execute
}
Second example:-
if(ConditionOne)
{
if(ConditionTwo )
{
if(ConditionThree)
{
Code to execute
}
}
}
which is easiest to understand and read bearing in mind that each condition may be a long function name or something.
© Stack Overflow or respective owner