{"name":"merge","title":"merge","type":"command","url":"https://community.bistudio.com/wiki/merge","revid":347592,"updated":"2023-09-28T20:05:03Z","groups":["HashMap"],"status":"ok","games":{"arma3":"2.02"},"since":"arma3 2.02","arma3_since":"2.02","description":"Merges two HashMaps.","syntaxes":[{"syntax":"hashMap1 merge hashMap2","params":[{"name":"hashMap1","type":"HashMap","description":"this HashMap will be modified","type_expr":"HashMap"},{"name":"hashMap2","type":"HashMap","description":"all key-value pairs from this HashMap are added to *hashMap1*. If a key from *hashMap2* already exists in *hashMap1*, it doesn't overwrite the value in *hashMap1*.","type_expr":"HashMap"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"hashMap1"},"right":{"text":"hashMap2"}},{"syntax":"hashMap1 merge [hashMap2, overwriteExisting]","params":[{"name":"hashMap1","type":"HashMap","description":"this HashMap will be modified","type_expr":"HashMap"},{"name":"hashMap2","type":"HashMap","description":"all key-value pairs from this HashMap are added to *hashMap1*","type_expr":"HashMap"},{"name":"overwriteExisting","type":"Boolean","optional":true,"default":"false","description":"if true, keys from *hashMap1* that also exist in *hashMap2* are overwritten. When set to true, merging is faster","type_expr":"Boolean","text":"overwriteExisting: Boolean - (Optional, default false) if true, keys from *hashMap1* that also exist in *hashMap2* are overwritten. When set to true, merging is faster"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"hashMap1"},"right":{"text":"[hashMap2, overwriteExisting]"}}],"examples":[{"code":["_hashMap merge _otherHashMap;"]},{"code":["private _hashmap1 = [\"cow\", \"cat\", \"chicken\"] createHashMapFromArray [100, 200, 200];\nprivate _hashmap2 = [\"cow\", \"cat\", \"chicken\", \"camel\"] createHashMapFromArray [150, 300, 400, 800];\n_hashmap1 merge _hashmap2; // _hashmap is [[\"cow\",100],[\"cat\",200],[\"chicken\",200],[\"camel\",800]]"]},{"code":["private _hashmap1 = [\"cow\", \"cat\", \"chicken\"] createHashMapFromArray [100, 200, 200];\nprivate _hashmap2 = [\"cow\", \"cat\", \"chicken\", \"camel\"] createHashMapFromArray [150, 300, 400, 800];\n_hashmap1 merge [_hashmap2, true]; // _hashmap is [[\"cow\",150],[\"cat\",300],[\"chicken\",400],[\"camel\",800]]"]},{"code":["private _hashmap1 = [\"cow\", \"cat\", \"chicken\"] createHashMapFromArray [100, 200, 200];\nprivate _hashmap2 = [\"cow\", \"cat\", \"chicken\", \"camel\"] createHashMapFromArray [150, 300, 400, 800];\n_hashmap1 merge [_hashmap2, false]; // _hashmap is [[\"cow\",100],[\"cat\",200],[\"chicken\",200],[\"camel\",800]] as Syntax 1"]}],"see_also":["insert","set"]}