insert: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 63: Line 63:
|x1= <sqf>"Test" insert [0, "Radio"]; // returns "RadioTest"</sqf>
|x1= <sqf>"Test" insert [0, "Radio"]; // returns "RadioTest"</sqf>


|seealso= [[HashMap]] [[pushBack]] [[pushBackUnique]] [[append]] [[a_plus_b|+]]
|seealso= [[HashMap]] [[pushBack]] [[pushBackUnique]] [[append]] [[a_plus_b|+]] [[merge]]
}}
}}

Revision as of 14:29, 8 August 2022

Hover & click on the images for description

Description

Description:
Inserts multiple values into Array/String/HashMap.
The String variant also supports forceUnicode.
Groups:
HashMapArraysStrings

Syntax 1

Syntax:
array insert [index, [value1, value2, ...], onlyIfUnique]
Parameters:
array : Array
index: Number - index at which the values will be inserted, -1 for append.
[value1, value2, ...]: Array of Anything - values to insert at the specified index
onlyIfUnique: Boolean - only insert if the value is unique in the array, like pushBackUnique
Return Value:
Nothing

Syntax 2

Syntax:
string insert [index, substring]
Parameters:
string : String
index: Number - index at which the values will be inserted, -1 for append.
substring: String - string to insert
Return Value:
String - the new string

Syntax 3

Syntax:
hashMap insert [[key1, value1], [key2, value2], ...]
Parameters:
hashMap: HashMap
key: HashMapKey
value: Anything
Return Value:
Nothing

Syntax 4

Syntax:
hashMap insert [splitArray, [keysAndValues]]
Parameters:
hashMap: HashMap
splitArray: Boolean - determines keysAndValues format (see keysAndValues's description)
keysAndValues: Array - in format depending on splitArray's value:
  • true - [[key1, key2, ...], [value1, value2, ...]]
  • false - [[key1, value1], [key2, value2], ...] (same as Syntax 3)
Return Value:
Nothing

Examples

Example 1:
"Test" insert [0, "Radio"]; // returns "RadioTest"

Additional Information

See also:
HashMap pushBack pushBackUnique append + merge

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