Arma 3 Scripting

Command in Arrays

resize

Also available as Markdown and JSON, or read the original wiki page.

Description

Changes the size of the given array. The command does not return new array, it resizes the source array to the desired number of elements. If the new size is bigger than the current size, the new places are filled with nil. The alternative syntax allows to fill resized positions with a given value. Array and HashMap values are copied.

Syntax

Syntax 1

array resize count

Parameters:

Returns: Nothing

Syntax 2

since arma3 2.10

array resize [count, fill]

Parameters:

Returns: Nothing

Examples

Example 1

_arrayNum = [0,1,2,3,4];
_arrayNum resize 2; // _arrayNum is now [0, 1]
_arrayNum resize 5; // _arrayNum is now [0, 1, nil, nil, nil]

Example 2

private _array = [0, 1, 2];
_array resize [5, -1]; // _array is now [0, 1, 2, -1, -1]

private _array = [0, 1, 2];
_array resize [1, -1]; // _array is now [0]

private _array = [0, 1, 2];
_array resize [4, "something"]; // _array is now [0, 1, 2, "something"]

See also

set · reverse · deleteAt · deleteRange

Community notes

DreadedEntity

Use this number to resize the array to the number of elements desired, not the desired index of the final element.

resize cannot be used to create a new array.