mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
22 lines
471 B
Plaintext
22 lines
471 B
Plaintext
/**
|
|
* fn_findIf.sqf
|
|
* @Descr: Get the first element that returns true.
|
|
* @Author: Glowbal
|
|
*
|
|
* @Arguments: [array ARRAY, if CODE (Code called for each element. Should return a bool)]
|
|
* @Return: ANY. Any element. Default return is an empty array ([])
|
|
* @PublicAPI: true
|
|
*/
|
|
|
|
private ["_array", "_if"];
|
|
_array = _this select 0;
|
|
_if = _this select 1;
|
|
|
|
_return = [];
|
|
{
|
|
if (_x call _if) exitwith {
|
|
_return = _array select _foreachIndex;
|
|
};
|
|
}foreach _array;
|
|
|
|
_return; |