Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
14.10 Hiding an else if construct
#1
The following

Code:
if ( x < 0 )
{
    log_error(3);
    x = 0;
}
else if ( y < 0 )
{
   x = 3;
}
else
{
/* no change */
}

Can be coded as

Code:
if ( x < 0 )
{
    log_error(3);
    x = 0;
}
else
{
   if ( y < 0 )
   {
      x = 3;
   }
}

to hide the "else if". Is this OK?

I think the code blocks are semantically identical but the last one does not list the else.

Brian
<t></t>


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)