On May 18, 4:40 am, jraul <jrauli...@yahoo.com> wrote:
> I have some code like:
>
> if( flagIsTrue )
> if( foo() )
> return false;
> else
> if( bar() )
> return false;
>
Your else hooks to the inmost if, so you better have aligned your code
like this
if( flagIsTrue )
if( foo() )
return false;
else
if( bar() )
return false;
Look, this has lots of logic, for if you tried something like this
if(...)
if(...)
else
and your 'else' would hook to the outmost 'if', you wouldnt be able to
add any more 'elses' as they would be separated from corresponding
inner 'if's :
if(a)
if(b)
else // since this one is outmost (second branch of a)
else // where should this go?
On the contrary, when 'else' hooks to the inmost 'if', you can do
constructs like:
if(a)
if(b)
if(c)
else // alt. branch of c
else // alt. branch of b
else // alt. branch of a
|