12.08.2010, 11:05
An if/else statement is called a conditional statement - if the condition is true, then that part will be evaluated.
There is no real difference between 'if' and 'else if' - except that the 'else if' will only be evaluated if the condition returns 'false'.
Let's say that this is your code:
All else if is, it's evaluated if that statement is false. The below example is exactly the same.
There is no real difference between 'if' and 'else if' - except that the 'else if' will only be evaluated if the condition returns 'false'.
Let's say that this is your code:
pawn Code:
new
iStatement = 2
if(iStatement == 0)
{
/*
This wouldn't be executed, because iStatement is 2.
*/
}
else if(iStatement == 1)
{
/*
This wouldn't be executed, because iStatement is 2.
*/
}
else if(iStatement == 2)
{
/*
This will be executed, because iStatement is 2, and there's a match.
*/
}
pawn Code:
new
iStatement = 2
if(iStatement == 0)
{
/*
This wouldn't be executed, because iStatement is 2.
*/
}
else
{
if(iStatement == 1)
{
/*
This wouldn't be executed, because iStatement is 2.
*/
}
else
{
if(iStatement == 2)
{
/*
This will be executed, because iStatement is 2, and there's a match.
*/
}
}
}