or: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Add since template usage)
Line 25: Line 25:
____________________________________________________________________________________________
____________________________________________________________________________________________


|s2= a [[or]] b        (''Since Arma 2:OA v1.62'') |SYNTAX2=
|s2= a [[or]] b {{since|arma2oa|1.62|y}} |SYNTAX2=


|p21= a: [[Boolean]] - test condition or variable |PARAMETER21=
|p21= a: [[Boolean]] - test condition or variable |PARAMETER21=
Line 36: Line 36:
|x1= <code>[[if]] (_obj1 [[or]] (_enemycount [[==]] 0) [[or]] ([[not]] [[alive]] _enemyGeneral)) [[then]] { [[hint]] "you win !"; };</code> |EXAMPLE1=
|x1= <code>[[if]] (_obj1 [[or]] (_enemycount [[==]] 0) [[or]] ([[not]] [[alive]] _enemyGeneral)) [[then]] { [[hint]] "you win !"; };</code> |EXAMPLE1=


|x2= <code>{{cc|without lazy evaluation [[select]] would throw an error if array was empty}}
|x2= <code>{{cc|without lazy evaluation, [[select]] would throw an error in the event of an empty array}}
[[if]] (([[count]] _array [[==]] 0) [[or]] { (_array [[select]] 0) [[!=]] [[player]] }) [[then]] {
[[if]] (([[count]] _array [[==]] 0) [[or]] { (_array [[select]] 0) [[!=]] [[player]] }) [[then]]
{
[[hint]] "It works!";
[[hint]] "It works!";
};</code> |EXAMPLE2=
};</code> |EXAMPLE2=
Line 43: Line 44:


| [[a or b|a || b]], [[and]], [[Operators]]|SEEALSO=
| [[a or b|a || b]], [[and]], [[Operators]]|SEEALSO=
|mp= |MP=
}}
}}


Line 55: Line 55:
<h3 style="display:none">Bottom Section</h3>
<h3 style="display:none">Bottom Section</h3>


[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.46|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.46|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]]

Revision as of 23:28, 23 December 2020

Hover & click on the images for description

Description

Description:
Returns true if one or both conditions are true. In case of the alternative syntax, lazy evaluation is used (if left operand is true, evaluation of the right side is skipped completely).
Identical to a || b.
Groups:
MathVariables

Syntax

Syntax:
a or b
Parameters:
a: Boolean - test condition or variable
b: Boolean - test condition or variable
Return Value:
Boolean

Alternative Syntax

Syntax:
a or b Template:since
Parameters:
a: Boolean - test condition or variable
b: Code - code that returns Boolean; it is not evaluated if a returns true
Return Value:
Boolean

Examples

Example 1:
if (_obj1 or (_enemycount == 0) or (not alive _enemyGeneral)) then { hint "you win !"; };
Example 2:
// without lazy evaluation, select would throw an error in the event of an empty array if ((count _array == 0) or { (_array select 0) != player }) then { hint "It works!"; };

Additional Information

See also:
a || bandOperators

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Bottom Section