02.07.2014, 10:48
(
Last edited by Rittik; 02/07/2014 at 11:23 AM.
)
Ternary Operators: Ternary operators deal with three operands.These operators are known as conditional operator as because the value assigned to a variable depends upon a logical expression.
Syntax:
variable= (test expression) ? Expression 1 : Expression 2;
Example:
@BroZeus: You should write a proper definition so that scripters can understand easily, writing "Basically ternary operator are used in place of "if" and "else" statements. They consists of a "?" and a ":" sign." will not do the work. As it is your first tutorial I'll suggest you to research before posting.Nice try though. I suggest all the scripters/coders to use if-else because it can be nested easily and you can profitably make your code execute.
Syntax:
variable= (test expression) ? Expression 1 : Expression 2;
Example:
pawn Code:
new a=5,b=3,max=0,min=0;
max=(a>b)? a:b;
// Here, the value 5 is stored in max as a>b is true.
min= (b>a)? a:b;
// Here, the value 3 is stored in min as b>a is false.