Help with the Conditions
#7

It depends whether you need the if statement to be processed whether a condition has been found.

pawn Код:
public OnPlayerConnect(playerid)
{
    new var = 5;

    if( var == 5 )
    {
    }
   
    if( var == 10 )//this will be processed even if you have already determined that var isn't 10
    {
    }

    return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
    new var = 5;

    if( var == 5 )
    {
        //because this is executed any following "else if" will not be processed.
    }

    else if( var == 10 )//this will not be processed if any statement above has been executed
    {
    }

    return 1;
}
It really doesn't matter too much normally, but it's good practice to use else if where possible.

You can find out more and get a much better description than i have given in almost any programming book. Most languages have if else if statements. If you know what "else" means in English you should have a fairly good understanding of what else if does.
Reply


Messages In This Thread
Help with the Conditions - by Saw® - 22.06.2012, 10:46
Re: Help with the Conditions - by .Wicked - 22.06.2012, 10:47
Re: Help with the Conditions - by iggy1 - 22.06.2012, 10:47
Re: Help with the Conditions - by Saw® - 22.06.2012, 10:51
Re: Help with the Conditions - by iggy1 - 22.06.2012, 10:52
Re: Help with the Conditions - by Saw® - 22.06.2012, 10:55
Re: Help with the Conditions - by iggy1 - 22.06.2012, 11:07
Re: Help with the Conditions - by Saw® - 22.06.2012, 11:16

Forum Jump:


Users browsing this thread: 1 Guest(s)