17.07.2014, 15:07
? true : false is called ternary operator.
It's a easy way to replace this:
With this:
'?' = if the condition proceeds
':' = else
Some examples:
It's a easy way to replace this:
pawn Код:
if(condition)
{
var = value;
}
else
{
var = anothervalue;
}
pawn Код:
var = (condition) ? value : anothervalue;
':' = else
Some examples:
pawn Код:
new value = 5;
new bool: isfive = (value == 5) ? true : false;
pawn Код:
new string[] = "hello world";
new bool: isempty = (strlen(string)) ? false : true;
pawn Код:
new Float: value = 0.0;
print("The float value %s.", (value > 0.0) ? ("isn't null") : ("is null"));

