Hi :-)
I think this is an incarnation of the "dangeling else" problem. For minimal example consider the following code:
1 2 3 4 5 6 7 8 9
|
if (a)
if (b)
{
// some code
}
// Does the statement started with if (a) end here?
else
// some code
// or here?
| |
There are two ways to interpret this code. The first is:
1 2 3 4 5 6 7 8 9 10 11
|
if (a)
{
if (b)
{
// some code
}
}
else
{
// some code
}
| |
Here the else belongs to the first if.
The second interpretation is
1 2 3 4 5 6 7 8 9 10 11
|
if (a)
{
if (b)
{
// some code
}
else
{
// some code
}
}
| |
Here the else belongs to the inner if. Maybe this example is to small to give the same error, as some compilers catch this.
The easiest way to circumvent this kind of problem is to
always use { and }, so it is unambiguously clear what you mean.
For more info, try googling for "dangeling else".
EDIT: I now see that this is not a dangeling else, but nonetheless its good to know about it :-)
Greetings, TheBear