{"name":"getOrDefaultCall","operator":null,"title":"getOrDefaultCall","type":"command","url":"https://community.bistudio.com/wiki/getOrDefaultCall","revid":378259,"updated":"2026-03-26T00:21:49Z","groups":["HashMap"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"2.12"}],"since":{"game":"arma3","name":"Arma 3","version":"2.12"},"arma3_since":"2.12","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Retrieves a value from the HashMap for the given 'key', executes given 'code' if key was not found and returns result.\nAdditionally sets key to the code result value if *set* is true.","syntaxes":[{"syntax":"hashMap getOrDefaultCall [key, code, set]","since":null,"effect":null,"exec":null,"params":[{"name":"hashMap","type":"HashMap","optional":false,"default":null,"description":null,"types":["HashMap"],"since":null,"text":"hashMap: HashMap"},{"name":"key","type":"HashMapKey","optional":false,"default":null,"description":"case-sensitive key","types":["HashMapKey"],"since":null,"text":"key: HashMapKey - case-sensitive key"},{"name":"code","type":"Code","optional":true,"default":"nil","description":"code to execute if the key does not exist","types":["Code"],"since":null,"text":"code: Code - (Optional, default nil) code to execute if the key does not exist"},{"name":"set","type":"Boolean","optional":true,"default":"false","description":"if true and value does not exist in the provided hash map, the result of the *code* execution is added to the hash map","types":["Boolean"],"since":null,"text":"set: Boolean - (Optional, default false) if true and value does not exist in the provided hash map, the result of the *code* execution is added to the hash map"}],"returns":{"type":"Anything","types":["Anything"],"description":null,"text":"Anything"},"form":"binary","operator":null,"left":{"text":"hashMap","types":["HashMap"]},"right":{"text":"[key, code, set]","types":["Array"]}}],"examples":[{"text":"```sqf\n_hashmap getOrDefaultCall [123, { systemChat \"The key 123 does not exist and will be created and assigned 345\"; 345 }, true];\n```","code":["_hashmap getOrDefaultCall [123, { systemChat \"The key 123 does not exist and will be created and assigned 345\"; 345 }, true];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["getOrDefault","HashMap","get"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: HashMap","Introduced with Arma 3 version 2.12","Scripting Commands"]}