Arma 3 Scripting

Command in HashMap, Arrays, Strings

insert

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

Description

Inserts multiple values into Array/String/HashMap.

The String variant also supports forceUnicode. In the event of a HashMap, values, if they already exist, are replaced.

Syntax

Syntax 1

array insert [index, valuesToInsert, onlyIfUnique]

Parameters:

Returns: Nothing

Syntax 2

string insert [index, substring]

Parameters:

Returns: String - the new string

Syntax 3

since arma3 2.04

hashMap insert [[key1, value1], [key2, value2], ...]

Parameters:

Returns: Nothing

Syntax 4

since arma3 2.04

hashMap insert [splitArray, [keysAndValues]]

Parameters:

Returns: Nothing

Examples

Example 1

"Test" insert [0, "Radio"];        // returns "RadioTest"
"Test" insert [2, "Radio"];        // returns "TeRadiost"
"Test" insert [-1, "Radio"];    // returns "TestRadio"

Example 2

private _array = ["a", "b", "c"];
_array insert [0, ["w"]]; // _array is now ["w", "a", "b", "c"]

private _array = ["a", "b", "c"];
_array insert [-1, ["w"]]; // _array is now ["a", "b", "c", "w"]

private _array = ["a", "b", "c"];
_array insert [-2, ["w"]]; // _array is now ["a", "b", "w", "c"] // Arma 3 v2.14

Example 3

// Notice how the size of the right array changes depending on the format of keysAndValues format
private _map = createHashMap;
_map insert [false, ["one", 1]];

private _map = createHashMap;
_map insert [true, ["one"], [1]];

See also

HashMap · pushBack · pushBackUnique · append · + · merge