Description
Links an If Type with Code to be executed if said If Type's condition is true; otherwise, "else" code is executed if provided.
The alternative syntax allows to set "then" code and "else" code in one array.
Note
Variables declared inside thenCode are private to that code block - see Variables#Local Variables Scope.
Syntax
ifType then thenCode
Parameters:
Returns: Anything - result of the executed code
Examples
Example 1
if (a > b) then { hint "a is greater than b!"; };
Example 2
private _c = 0;
if (_a > _b) then
{
_c = 1;
}
else
{
_c = 2;
};
Example 3
if (alive player) then [{ hint "player is alive"; }, { hint "player is dead"; }];
Example 4
private _value = if (alive player) then { 1 } else { 0 };
See also
Control Structures · if · else