findAny: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Page creation)
 
m (Text replacement - "\|branch= *dev " to "")
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
|version1= 2.10
|version1= 2.10


|branch= dev


|descr= Returns the zero-based index of the first element in array A that also exists in array B. If no common elements exist it returns -1.<br>
|descr= Returns the zero-based index of the first element in array A that also exists in array B. If no common elements exist it returns -1.<br>
Line 19: Line 18:
|r1= [[Number]] - the index of the first found item
|r1= [[Number]] - the index of the first found item


|x1= <code>[0,1,2,3,4] [[findAny]] [2,4,6,8]; {{cc|returns 2}}</code>
|x1= <sqf>[0,1,2,3,4] findAny [2,4,6,8]; // returns 2</sqf>


|x2= <code>[0,1,2,3,4] [[findAny]] [8,6,4,2]; {{cc|returns 2}}</code>
|x2= <sqf>[0,1,2,3,4] findAny [8,6,4,2]; // returns 2</sqf>


|x3= <code>[0,1,2,3,4] [[findAny]] [5,7,9]; {{cc|returns -1}}</code>
|x3= <sqf>[0,1,2,3,4] findAny [5,7,9]; // returns -1</sqf>


|seealso= [[find]] [[findIf]]
|seealso= [[find]] [[findIf]]
}}
}}

Latest revision as of 14:23, 23 August 2022

Hover & click on the images for description

Description

Description:
Returns the zero-based index of the first element in array A that also exists in array B. If no common elements exist it returns -1.
Similar in functionality as find's first syntax, but the second parameter is an array of elements to find.
Groups:
Arrays

Syntax

Syntax:
searchIn findAny toFind
Parameters:
searchIn: Array
toFind: Array
Return Value:
Number - the index of the first found item

Examples

Example 1:
[0,1,2,3,4] findAny [2,4,6,8]; // returns 2
Example 2:
[0,1,2,3,4] findAny [8,6,4,2]; // returns 2
Example 3:
[0,1,2,3,4] findAny [5,7,9]; // returns -1

Additional Information

See also:
find findIf

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