Arma 3 Scripting

Function in Arrays

BIS_fnc_addToPairs

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

Description

Adds given value to pair array, stored under unique key.

If value is found:

a) both values are scalars: values are added and stored as a single scalar

b) one or both values are array: values are added and stored as a single array

c) anything else: an array is created and both values are stored there

Note

Function by default modifies the input array. This can be overrriden by setting '_copyArray' param to true.

Syntax

[array, key, value, copyArray] call BIS_fnc_addToPairs

Parameters:

Returns: Array - resulting modified array or a copy

Examples

Example 1

[[["apple",3],["pear",2]],"pear",10] call BIS_fnc_addToPairs; // Returns [["apple",3],["pear",12]]

Example 2

[[["apple",3],["pear",2]],"apple",-2] call BIS_fnc_addToPairs; // Returns [["apple",1],["pear",2]]

Example 3

[[["greetings","Hello!"],["rudewords",""]],"greetings","Hi!"] call BIS_fnc_addToPairs; // Returns [["greetings",["Hello!","Hi!"]],["rudewords",""]]

See also

find · findIf · BIS_fnc_findInPairs · BIS_fnc_getFromPairs · BIS_fnc_removeFromPairs · BIS_fnc_setToPairs