ACE3/TO_MERGE/cse/main/arrays/functions/fn_findIf.sqf
2015-01-12 23:35:40 +01:00

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;