The funny thing about "else if"

Just noticed something funny a few weeks back.

To recap, if statements can be written without brackets. If this is done, the very next line is executed, that only that line if the query is met. Same thing after ‘else’.

if (you.areGay == true)
   me.runAway();
else
   me.befriend(you);

Now, many languages have “else if” as “ifelse” or something instead, all one word. However, let’s take a look at how Flash does it:

if (you.areGay == true)
   me.runAway();
else if (you.areGay == false)
   me.befriend(you);

Notice something funny? Really, the above line can be interpreted as “if, then one line that is executed” followed by “else, then one line that is executed”. On that one line, just so happens to be another if statement. If you put several else if statements in a row, you get the following:

if (you.areGay == true)
    me.runAwayAndDontTurnMyBackOnYou();
else if (you.areBi == true)
   me.runAway();
else if (you.areSociopath == true)
   me.runFaster();
else
   me.befriend(you);

Notice that all the if statements in the above code are really if statements followed by one line, which is another if statement, followed by another one line if statement after the else, etc. When you add proper brackets, you will get the exact same results as below:

if (you.areGay == true)
{
   me.runAwayAndDontTurnMyBackOnYou();
}
else 
{
   if (you.areBi == true)
   {
      me.runAway();
   }
   else 
   {
      if (you.areSociopath == true)
      {
         me.runFaster();
      }
      else
      {
         me.befriend(you);
      }
   }
}

Of course, I prefer the 8 lines to 22, so it is quite convenient.

Is my guess on how it works and compiles correct? Or is Flash smart enough to treat “else if” differently"?