BIS fnc addToPairs: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 30: | Line 30: | ||
|p4= copyArray: [[Boolean]] - (Optional, default [[false]]) [[True]] to copy the array and return it, [[false]] to modify the original array | |p4= copyArray: [[Boolean]] - (Optional, default [[false]]) [[True]] to copy the array and return it, [[false]] to modify the original array | ||
|r1= [[ | |r1= [[Array]] - Resulting modified array or a copy | ||
|x1= <code>[[["apple",3],["pear",2]],"pear",10] [[call]] [[BIS_fnc_addToPairs]]; {{cc|Returns [["apple",3],["pear",12]]}}</code> | |x1= <code>[[["apple",3],["pear",2]],"pear",10] [[call]] [[BIS_fnc_addToPairs]]; {{cc|Returns [["apple",3],["pear",12]]}}</code> |
Revision as of 10:52, 15 September 2020
Description
- 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
- Execution:
- call
- Groups:
- Uncategorised
Syntax
- Syntax:
- [array, key, value, copyArray] call BIS_fnc_addToPairs
- Parameters:
- array: Array - Array to search through
- key: String - Key to search for
- value: Number - (Optional, default nil) Default return value if no match was found
- copyArray: Boolean - (Optional, default false) True to copy the array and return it, false to modify the original array
- Return Value:
- 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",""]]
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