Patterns of Bugs

Iain Buclaw ibuclaw at ubuntu.com
Sat Jan 8 12:37:02 PST 2011


== Quote from torhu (no at spam.invalid)'s article
> On 08.01.2011 15:13, Iain Buclaw wrote:
> >
> > On the note of if statements. One pattern of bugs I see on the odd occasion
are
> > else statements written like this:
> >
> > if (condition1)
> >      if (condition2)
> >          statement1;
> >      else
> >          statement2;
> >
> >
> > Always takes a moment or two to look again and realise it wouldn't work as
> > expected without the missing braces added. ;)
> But that one would actually work as expected, wouldn't it? ;) The else
> belongs to the second if, which matches your indentation.

Never let indentation fool you, the else clause will be assumed to be for the
first condition. :o)


More information about the Digitalmars-d mailing list