Page MenuHomeFeedback Tracker

A command to return value from hashmap by key and calculate default value only if key is missing
Closed, ResolvedPublic

Description

I would like to request a command similar to getOrDefault except default value will be calculated from provided code only if provided key is missing.

Primary usage - quick retrieval and caching of values in the hashmap.

Details

Severity
Feature
Resolution
Open
Reproducibility
N/A
Operating System
Windows 10 x64
Category
Scripting
Additional Information

Suggested names: getOrCall, getOrDefaultCall
Suggested syntax:
Any = HashMap getOrCall [Key, Code, SetFlag]
Key - HashMap key
Code - Code to call if key is not found
SetFlag - flag to set result of code execution alongside returning it, might be false by default to be in line with getOrDefault command

Code's scope might include key and hashmap in some magic variables (_thisMap, _thisKey) without touching _this, so arguments and local variables from higher scope are still accessible.

Event Timeline

SaMatra created this task.Sep 8 2022, 11:17 AM
BIS_fnc_KK changed the task status from New to Feedback.Sep 8 2022, 1:58 PM
This comment was removed by BIS_fnc_KK.
dedmen set Ref Ticket to AIII-55365.Nov 14 2022, 12:29 PM

Did a brief testing, works good.

dedmen closed this task as Resolved.Sep 26 2023, 1:53 PM
dedmen claimed this task.