set: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Link to wrong example)
(You know the rules and so do I (add HashMap set))
Line 18: Line 18:
|p2= [index, value]: [[Array]] |PARAMETER2=
|p2= [index, value]: [[Array]] |PARAMETER2=
|p3= index: [[Number]] |PARAMETER3=
|p3= index: [[Number]] |PARAMETER3=
|p4= value: [[Anything]] |PARAMETER4=
| [[Nothing]] |RETURNVALUE=
____________________________________________________________________________________________
| hashMap '''set''' [key, value] |SYNTAX=
|p1= hashMap : [[HashMap]] |PARAMETER1=
|p2= [key, value]: [[Array]] |PARAMETER2=
|p3= key: [[HashMapKey]] |PARAMETER3=
|p4= value: [[Anything]] |PARAMETER4=
|p4= value: [[Anything]] |PARAMETER4=



Revision as of 10:47, 15 December 2020

Hover & click on the images for description

Description

Description:
Changes the element at the given (zero-based) index of the array.
If the index is out of bounds, the array will resize to incorporate the index as its last value, padding with nil as necessary. See Example 4.
Groups:
Arrays

Syntax

Syntax:
array set [index, value]
Parameters:
hashMap : HashMap
[key, value]: Array
key: HashMapKey
value: Anything
Return Value:
Nothing

Examples

Example 1:
_arrayOne set [0, "Hello"];
Example 2:
Append "Bye" as last element to _arrayTwo:
_arrayTwo set [count _arrayTwo, "Bye"];
Example 3:
Replace the last element of _arrayThree with 23:
_arrayThree set [(count _arrayThree) - 1, 23];
Example 4:
Using set with an index that is out of bounds:
_array = ["A"]; _array set [2, "C"]; // _array is now ["A", nil, "C"] _array set [1, "B"]; // _array is now ["A", "B", "C"]

Additional Information

See also:
hashMap set [key, value]

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

Notes

Bottom Section