{"name":"merge","operator":null,"title":"merge","type":"command","url":"https://community.bistudio.com/wiki/merge","revid":347592,"updated":"2023-09-28T20:05:03Z","groups":["HashMap"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"2.02"}],"since":{"game":"arma3","name":"Arma 3","version":"2.02"},"arma3_since":"2.02","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Merges two HashMaps.","syntaxes":[{"syntax":"hashMap1 merge hashMap2","since":null,"effect":null,"exec":null,"params":[{"name":"hashMap1","type":"HashMap","optional":false,"default":null,"description":"this HashMap will be modified","types":["HashMap"],"since":null,"text":"hashMap1: HashMap - this HashMap will be modified"},{"name":"hashMap2","type":"HashMap","optional":false,"default":null,"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*.","types":["HashMap"],"since":null,"text":"hashMap2: HashMap - 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*."}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"hashMap1","types":["HashMap"]},"right":{"text":"hashMap2","types":["HashMap"]}},{"syntax":"hashMap1 merge [hashMap2, overwriteExisting]","since":null,"effect":null,"exec":null,"params":[{"name":"hashMap1","type":"HashMap","optional":false,"default":null,"description":"this HashMap will be modified","types":["HashMap"],"since":null,"text":"hashMap1: HashMap - this HashMap will be modified"},{"name":"hashMap2","type":"HashMap","optional":false,"default":null,"description":"all key-value pairs from this HashMap are added to *hashMap1*","types":["HashMap"],"since":null,"text":"hashMap2: HashMap - all key-value pairs from this HashMap are added to *hashMap1*"},{"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","types":["Boolean"],"since":null,"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","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"hashMap1","types":["HashMap"]},"right":{"text":"[hashMap2, overwriteExisting]","types":["Array"]}}],"examples":[{"text":"```sqf\n_hashMap merge _otherHashMap;\n```","code":["_hashMap merge _otherHashMap;"]},{"text":"```sqf\nprivate _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]]\n```","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]]"]},{"text":"```sqf\nprivate _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]]\n```","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]]"]},{"text":"```sqf\nprivate _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\n```","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"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["insert","set"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: HashMap","Introduced with Arma 3 version 2.02","Scripting Commands"]}