BIS fnc arrayShift: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - " <h3 style="display:none">Notes</h3> <dl class="command_description"> <!-- Note Section BEGIN --> <!-- Note Section END --> </dl>" to "") |
Lou Montana (talk | contribs) m (Text replacement - " *\| *([Cc]omments|COMMENTS|[Gg]ame [Nn]ame|Game [Vv]ersion|Game Version \(number surrounded by NO SPACES\)|Multiplayer Arguments \("local" or "global"\)|Multiplayer Effects \("local" or "global"\)|Multiplayer Execution \("server" o...) |
||
Line 1: | Line 1: | ||
{{Function | {{Function | ||
| arma2 | | arma2 | ||
|1.00 | |1.00 | ||
|gr1= Arrays | |gr1= Arrays | ||
| This function removes the first (leftmost) element of an array and returns it.<br> | | This function removes the first (leftmost) element of an array and returns it.<br> | ||
The array is passed by reference so changes inside the function will be reflected outside of it.<br> | The array is passed by reference so changes inside the function will be reflected outside of it.<br> | ||
<br> | <br> | ||
Similar to {{Inline code|array [[deleteAt]] 0}}. | Similar to {{Inline code|array [[deleteAt]] 0}}. | ||
| [array] call [[BIS_fnc_arrayShift]] | | [array] call [[BIS_fnc_arrayShift]] | ||
|p1= array: [[Array]] - '''NOTE:''' given array must be within an array (e.g {{Inline code|<nowiki>[</nowiki>[10, 20, 30]] call BIS_fnc_arrayShift}}) | |p1= array: [[Array]] - '''NOTE:''' given array must be within an array (e.g {{Inline code|<nowiki>[</nowiki>[10, 20, 30]] call BIS_fnc_arrayShift}}) | ||
| [[Anything]] - the removed element | | [[Anything]] - the removed element | ||
|x1= <code>_myArray = ["2", "report", "status"]; | |x1= <code>_myArray = ["2", "report", "status"]; | ||
_removedElement = [_myArray] [[call]] [[BIS_fnc_arrayShift]]; {{codecomment|// array is '''within an array'''}} | _removedElement = [_myArray] [[call]] [[BIS_fnc_arrayShift]]; {{codecomment|// array is '''within an array'''}} | ||
_removedElement == "2"; {{codecomment|// true}} | _removedElement == "2"; {{codecomment|// true}} | ||
_myArray [[isEqualTo]] ["report", "status"]; {{codecomment|// true}}</code> | _myArray [[isEqualTo]] ["report", "status"]; {{codecomment|// true}}</code> | ||
| [[deleteAt]], [[pushBack]] | | [[deleteAt]], [[pushBack]] | ||
}} | }} | ||
Revision as of 22:36, 17 January 2021
Description
- Description:
- This function removes the first (leftmost) element of an array and returns it.
The array is passed by reference so changes inside the function will be reflected outside of it.
Similar toarray deleteAt 0
. - Execution:
- call
- Groups:
- Arrays
Syntax
- Syntax:
- [array] call BIS_fnc_arrayShift
- Parameters:
- array: Array - NOTE: given array must be within an array (e.g
[[10, 20, 30]] call BIS_fnc_arrayShift
) - Return Value:
- Anything - the removed element
Examples
- Example 1:
_myArray = ["2", "report", "status"]; _removedElement = [_myArray] call BIS_fnc_arrayShift; // array is within an array _removedElement == "2"; // true _myArray isEqualTo ["report", "status"]; // true
Additional Information
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