08.09.2012, 22:16
Well basically it's an if-statement in an expression. For example:
Could also be written as:
The hooks are optional, but I usually add them to keep code readable.
In the case of if-else if-else statements:
becomes...
pawn Код:
new val = 4;
new otherval;
if(val == 8)
{
othervalval = 6;
}
else
{
othervalval = 12;
}
pawn Код:
new val = 4;
new otherval;
otherval = (val == 8) ? (6) : (12);
In the case of if-else if-else statements:
pawn Код:
if(a == 4)
{
b = 8;
}
else if(a == 3)
{
b = 13;
}
else
{
b = 2;
}
pawn Код:
b = (a == 4) ? (8) : (a == 3) ? (13) : 2;