Page MenuHomeFeedback Tracker

Poor exitWith behaviour for getOrDefaultCall
Closed, ResolvedPublic

Description

exitWith seems to jump a level too far in getOrDefaultCall's code parameter, making it irritating to use correctly. Repro code provided.

Also lacks a (documented?) magic variable for reading the input key, which seems like a strange omission.

Details

Severity
Minor
Resolution
Not A Bug
Reproducibility
Always
Operating System
Windows 10 x64
Category
Scripting
Steps To Reproduce
_testHM = createHashMap;
_testHM getOrDefaultCall ["wibble", { if (true) exitWith {0} }, true];
_testHM

returns: [["wibble",<null>]]

Event Timeline

jaj22 created this task.Jul 29 2023, 5:09 PM
BIS_fnc_KK added a subscriber: BIS_fnc_KK.EditedJul 30 2023, 11:00 AM

Thats the perks of exitWith https://community.bistudio.com/wiki/exitWith

if you absolutely must use exitWith in that expression, wrap it in call

_testHM = createHashMap;
_testHM getOrDefaultCall ["wibble", { call {if (true) exitWith {0}} }, true];
_testHM

returns: [["wibble",0]]
BIS_fnc_KK closed this task as Resolved.Jul 30 2023, 11:01 AM
BIS_fnc_KK changed Resolution from Open to Not A Bug.