Text 4 Jan AS3 Notes 0002

Cannot place an Else in another Else?

While playing with the if conditional statement in my free time, I uses an Else If inside an If statement:

line 1: if (x<=5){

line 2: if (x==1){

line 3: statement}

line 4: else if (x==2){

line 5: statement}

line 6: }

line 7: else if (x>=5){

line 8: }

and error shows up in the compiler, stating that the the “Else if” in line 4 is an error, but it didn’t further explaining the reason why. That’s what has been bugging me, cuz I’m pretty sure that I’ve done the same thing in my previous work without encountering any errors… weird!


Design crafted by Prashanth Kamalakanthan. Powered by Tumblr.