createHashMapFromArray: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " |game1= arma3dev |version1= 2.01" to " |game1= arma3 |version1= 2.02")
(added alt syntax)
Line 16: Line 16:


|r1= [[HashMap]]
|r1= [[HashMap]]
|s1= keys [[createHashMapFromArray]] values {{Since|arma3|2.04|y}}
|p1= keys: [[Array]] - Array of [[HashMapKey]]s
|p2= values: [[Array]] - Array of [[Anything|anything]]
{{Feature|Informative|Size of ''keys'' and size of ''values'' arrays do not need to be equal. Missing values will be filled with [[null]].}}
|r2= [[HashMap]]


|x1= <code>[[createHashMapFromArray]] [["a",1], ["b",2], ["c",3]];</code>
|x1= <code>[[createHashMapFromArray]] [["a",1], ["b",2], ["c",3]];</code>
|x2= <code>[1,2,3,4] [[createHashMapFromArray]] [];{{cc|Returns [[1,<null>],[2,<null>],[4,<null>],[3,<null>]]}}</code>
|x3= <code>[1,2,3] [[createHashMapFromArray]] ["one","two","three","four"];{{cc|Returns [[1,"one"],[2,"two"],[3,"three"]]}}</code></code>


|seealso=  [[createHashMap]]
|seealso=  [[createHashMap]]
}}
}}

Revision as of 15:28, 16 April 2021

Hover & click on the images for description

Description

Description:
Creates a new HashMap and initializes it from a key-value pair array
Groups:
HashMap

Syntax

Syntax:
keys createHashMapFromArray values Template:Since
Parameters:
keys: Array - Array of HashMapKeys
values: Array - Array of anything
Size of keys and size of values arrays do not need to be equal. Missing values will be filled with null.
Return Value:
HashMap

Examples

Example 1:
createHashMapFromArray [["a",1], ["b",2], ["c",3]];
Example 2:
[1,2,3,4] createHashMapFromArray [];// Returns [[1,<null>],[2,<null>],[4,<null>],[3,<null>]]
Example 3:
[1,2,3] createHashMapFromArray ["one","two","three","four"];// Returns [[1,"one"],[2,"two"],[3,"three"]]

Additional Information

See also:
createHashMap

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