in Array: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
(redirect)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|= Comments
#REDIRECT [[in]]
____________________________________________________________________________________________
 
| ofp |= Game name
 
|1.00|= Game version
 
|arg= local |= Arguments in MP
____________________________________________________________________________________________
 
| Checks whether x is equal to any element in the array. If x is a string, the array is checked ''case-sensitive'' (see Example 2).
 
Note you can not test for arrays within arrays using this command. |= Description
____________________________________________________________________________________________
 
| ''x'' '''in''' array |= Syntax
|p1 = x: [[Any Value]] except [[Array]]
|p2 = array: [[Array]]
| [[Boolean]] |= Return value
____________________________________________________________________________________________
|x1 = <code> 1 '''in''' [0, 1, 2] </code>
 
Result is true 
|x2 = <code> "lol" '''in''' ["Lol", "LOL", "loL"] </code>
 
Result is false
|[[set]], [[resize]], [[reverse]], [[pushBack]], [[select]], [[in]], [[find]], [[toArray]], [[toString]], [[forEach]], [[count]] |= See also
 
}}
 
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on 15:58, 18 January 2007 (CET)
<dt class="note">'''[[User:T_D|T_D]]'''<dd class="note">
For a case-''insensitive'' test use [[count]]:
<code>{_x == "lol"} [[count]] ["Lol", "LOL", "loL"]; //returns 3.</code>
Checking if an array (for example a position) is in another array doesn't produce an error, but it will always return false. e.g.
<code>[0,0,0] '''in''' [[0,0,0],[1,4,3],[5,3,1]]; //returns: false.</code>
<!-- Note Section END -->
</dl>
 
<h3 style="display:none">Bottom Section</h3>
[[Category:Scripting Commands|INARRAY]]
[[Category:Scripting Commands OFP 1.96|INARRAY]]
[[Category:Scripting Commands OFP 1.46|INARRAY]]
[[Category:Scripting Commands ArmA|INARRAY]]
[[Category:Command_Group:_Variables|{{uc:{{PAGENAME}}}}]]
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on July 16, 2014 - 08:12 (UTC)</dd>
<dt class="note">'''[[User:Killzone Kid|Killzone Kid]]'''</dt>
<dd class="note">
Correction to the note above ^^^. In order to detect array in array, the argument has to be on the same "level" as in the array: [1,2,3] in [[1,2,3],[4,5,6]] will be false, but [<nowiki>[</nowiki>1,2,3]] in [[1,2,3],[4,5,6]] will be true.
</dd>
</dl>
<!-- DISCONTINUE Notes -->
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on August 23, 2014 - 10:10 (UTC)</dd>
<dt class="note">[[User:PabstMirror|PabstMirror]]</dt>
<dd class="note">
As of 1.26:
<code>[0,0,0] in [[0,0,0],[1,4,3],[5,3,1]]; //returns true
[1,2,3] in [[1,2,3],[4,5,6]]; //returns true
[[1,2,3]] in [[1,2,3],[4,5,6]]; //returns false</code>
Assuming it is now using comparison as found in isEqualTo
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 21:07, 3 February 2016

Redirect to: