ternary operator
#8

Ternary operators exists to reduce the lines of code, and make the if statement somehow, more "flexible"[I can't describe it in a better word]

For example, you want to add "1" to the variable "randomvar" if the variable "tfalse" is true, or add "5" if the variable "tfalse" is false.
In the traditional programming, you would do this:
pawn Code:
if(tfalse)
    randomvar = 1;
else
    randomvar = 5;
So, with the ternary operator, you do:
pawn Code:
randomvar = (tfalse) ? 1 : 5;
Smaller, more "flexible", and it simply does what you need.
Reply


Messages In This Thread
ternary operator - by SnL - 18.02.2014, 20:21
Re: ternary operator - by Patrick - 18.02.2014, 20:31
Re: ternary operator - by SnL - 18.02.2014, 20:36
Re: ternary operator - by Patrick - 18.02.2014, 20:37
Re: ternary operator - by SnL - 18.02.2014, 20:40
Re: ternary operator - by GWMPT - 18.02.2014, 20:43
Re: ternary operator - by SnL - 18.02.2014, 20:49
Re: ternary operator - by GWMPT - 18.02.2014, 20:53
Re: ternary operator - by SnL - 18.02.2014, 20:56

Forum Jump:


Users browsing this thread: 1 Guest(s)