getOrDefault: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\| *p([0-9]) *=([^ ]+) *\{\{Since\|(.+)\|([0-9]\.[0-9][02468])[^ ]+\}\} " to "|p$1= $2 |p$1since= $3 $4 ") |
Lou Montana (talk | contribs) m (Text replacement - " \|([ps][0-9]+) *= " to " |$1= ") |
||
Line 16: | Line 16: | ||
|p3= defaultValue: [[Anything]] - (Optional, default [[nil]]) | |p3= defaultValue: [[Anything]] - (Optional, default [[nil]]) | ||
|p4= | |p4= setDefault: [[Boolean]] - (Optional, default [[false]]) - If set to [[true]] and value does not exist in provided hash map, '''defaultValue''' will be added to the hash map | ||
|p4since= arma3 2.04 | |p4since= arma3 2.04 | ||
Revision as of 00:30, 11 August 2021
Description
- Description:
- Retrieves a value out of a HashMap after looking it up by its key. When the HashMap doesn't contain the key, the default value is returned
- Groups:
- HashMap
Syntax
- Syntax:
- hashMap getOrDefault [key, defaultValue]
- Parameters:
- hashMap : HashMap
- key: HashMapKey - Case sensitive key
- defaultValue: Anything - (Optional, default nil)
- since
2.04
- setDefault: Boolean - (Optional, default false) - If set to true and value does not exist in provided hash map, defaultValue will be added to the hash map
- Return Value:
- Anything
Examples
- Example 1:
private _myValue = _myHashMap getOrDefault ["a", "Not Found!"];
- Example 2:
private _myValue = _hashMap getOrDefault ["a", "Not Found!", true]; // Will add default value to the hash map if it does not exist
Additional Information
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note