{"name":"getOrDefaultCall","title":"getOrDefaultCall","type":"command","url":"https://community.bistudio.com/wiki/getOrDefaultCall","revid":378259,"updated":"2026-03-26T00:21:49Z","groups":["HashMap"],"status":"ok","games":{"arma3":"2.12"},"since":"arma3 2.12","arma3_since":"2.12","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]","params":[{"name":"hashMap","type":"HashMap","type_expr":"HashMap"},{"name":"key","type":"HashMapKey","description":"case-sensitive key","type_expr":"HashMapKey"},{"name":"code","type":"Code","optional":true,"default":"nil","description":"code to execute if the key does not exist","type_expr":"Code","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","type_expr":"Boolean","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","type_expr":"Anything"},"form":"binary","left":{"text":"hashMap"},"right":{"text":"[key, code, set]"}}],"examples":[{"code":["_hashmap getOrDefaultCall [123, { systemChat \"The key 123 does not exist and will be created and assigned 345\"; 345 }, true];"]}],"see_also":["getOrDefault","HashMap","get"]}