Explanation needed.
#7

Well basically it's an if-statement in an expression. For example:
pawn Код:
new val = 4;
new otherval;
if(val == 8)
{
    othervalval = 6;
}
else
{
    othervalval = 12;
}
Could also be written as:
pawn Код:
new val = 4;
new otherval;
otherval = (val == 8) ? (6) : (12);
The hooks are optional, but I usually add them to keep code readable.

In the case of if-else if-else statements:
pawn Код:
if(a == 4)
{
    b = 8;
}
else if(a == 3)
{
    b = 13;
}
else
{
    b = 2;
}
becomes...

pawn Код:
b = (a == 4) ? (8) : (a == 3) ? (13) : 2;
Reply


Messages In This Thread
Explanation needed. - by TaLhA XIV - 08.09.2012, 18:31
Re: Explanation needed. - by Glint - 08.09.2012, 18:33
Re: Explanation needed. - by TaLhA XIV - 08.09.2012, 18:50
Re: Explanation needed. - by TaLhA XIV - 08.09.2012, 20:00
Re: Explanation needed. - by SuperViper - 08.09.2012, 20:02
Re: Explanation needed. - by TaLhA XIV - 08.09.2012, 20:13
Re: Explanation needed. - by Hiddos - 08.09.2012, 22:16

Forum Jump:


Users browsing this thread: 1 Guest(s)