createHashMapFromArray: Difference between revisions

From Bohemia Interactive Community
mNo edit summary
mNo edit summary
Line 10: Line 10:
|descr= Creates a new [[HashMap]] and initializes it from a key-value pair array
|descr= Creates a new [[HashMap]] and initializes it from a key-value pair array


|s1= [[createHashMapFromArray]] [[key1, value1], [key2, value2]]  
|s1= [[createHashMapFromArray]] [[key1, value1], [key2, value2], ...]  


|p1= keyN: [[HashMapKey]]
|p1= keyN: [[HashMapKey]]

Revision as of 01:09, 2 January 2026

{{RV|type=command

|game1= arma3 |version1= 2.02

|gr1= HashMap

|gr2= Arrays

|descr= Creates a new HashMap and initializes it from a key-value pair array

|s1= createHashMapFromArray [[key1, value1], [key2, value2], ...]

|p1= keyN: HashMapKey

|p2= valueN: Anything

|r1= HashMap

|s2= keys createHashMapFromArray values

|s2since= arma3 2.04

|p21= keys: Array of HashMapKeys

|p22= values: Array of Anything

Size of keys and size of values arrays do not need to be equal. Missing values will be filled with nil.

|r2= HashMap

|x1=

createHashMapFromArray [["a", 1], ["b", 2], ["c", 3]];

|x2=

[1, 2, 3, 4] createHashMapFromArray []; // returns [[1, <null>], [2, <null>], [4, <null>], [3, <null>]]

|x3=

[1, 2, 3] createHashMapFromArray ["one", "two", "three", "four"]; // returns [[1, "one"], [2, "two"], [3, "three"]]

|seealso= createHashMap }}