01.06.2014, 13:54
It's an alternative to 'if' and 'else'.
Could be written as:
Personally, since I discovered ternary operators, I have loved them because they reduce everything into 1 simple line and their concept is easy to grasp. They are very useful. Slice's thread gives a very good example of their usage.
pawn Code:
if(cond == true)
{
if(cond2 == true) var = 15;
else if(cond2 == false) var = 25;
}
else if(cond == false) var = 60;
pawn Code:
new var = (cond == true) ? ((cond2 == true) ? (15) : (25)) : (60);