01.06.2014, 11:18
yes they are called ternary operator i will tell how they work so here is it
Syntax Condition ? Value1 : Value 2
How it works?-- If the condition is true then it returns Value1 and if condition is false then it returns Value2
Examples and its outputs-
taking an simple example --
So in the above example the value of a will finally be 1 because the condition is true if condition had been (b>c) then value of a will be 0
There is more complex way of using it by using one ternary operator inside another those are used in place of nested loop and are very difficult to understand
I recommend you to use this only when you have a simple if else statement condition. Only if you are expertise in it then use it in place of nested if-else
Syntax Condition ? Value1 : Value 2
How it works?-- If the condition is true then it returns Value1 and if condition is false then it returns Value2
Examples and its outputs-
taking an simple example --
pawn Code:
//Example
new a,b,c;
b=10;
c=20;
a= (b<c) ? 1 : 0;
There is more complex way of using it by using one ternary operator inside another those are used in place of nested loop and are very difficult to understand
I recommend you to use this only when you have a simple if else statement condition. Only if you are expertise in it then use it in place of nested if-else