Description
Checks whether value is in array, unit is in vehicle, position is inside location or ANSI string is part of other ANSI string. If Unicode support is desired, see forceUnicode.
Note
String comparison is case-sensitive (see Examples 2 and 6).
Syntax
Syntax 1
value in array
Parameters:
Returns: Boolean
Syntax 2
unit in vehicle
Parameters:
Returns: Boolean
Syntax 3
since arma3 0.50
position in location
Parameters:
position: Position2D or Position3Dlocation: Location
Returns: Boolean
Syntax 4
since arma3 1.96
needle in haystack
Parameters:
Returns: Boolean
Syntax 5
since arma3 2.02
key in hashMap
Parameters:
key: HashMapKeyhashMap: HashMap
Returns: Boolean
Examples
Example 1
1 in [0, 1, 2]; // true
Example 2
private _myArray = ["Aaa", "AAa", "AAA"];
"aaa" in _myArray; // false
"AAa" in _myArray; // true
// Case-insensitive alternatives:
_myArray findIf { _x == "aaa"; } != -1; // true
({
if (_x == "aaa") exitWith { _forEachIndex };
-1
} forEach _myArray) != -1; // true, less performant but valid before the introduction of the findIf command
{ if (_x == "aaa") exitWith { 1 } } count _myArray > 0; // true
{ _x == "aaa"; } count _myArray > 0; // true, worst performance, only option available in OFP
Example 3
[1,2,3] in [[1,2,3], [4,5,6]]; // true - Arma 3 only
Example 4
private _isInCar = player in Car;
Example 5
private _isInside = [1000,2000,0] in MyLocation;
Example 6
private _isInString = "foo" in "foobar"; // true
_isInString = "Foo" in "foobar"; // false
Example 7
private _onFoot = _unit in _unit;
Other options:
private _onFoot = vehicle _unit == _unit;
private _onFoot = isNull objectParent _unit;