Merge pull request #88345 from SysError99/3.x-get_or_add

[3.x] Add a `get_or_add` method to Dictionary
This commit is contained in:
lawnjelly
2024-04-04 13:04:16 +01:00
committed by GitHub
4 changed files with 20 additions and 0 deletions

View File

@@ -131,6 +131,14 @@
Returns the current value for the specified key in the [Dictionary]. If the key does not exist, the method returns the value of the optional default argument, or [code]null[/code] if it is omitted.
</description>
</method>
<method name="get_or_add">
<return type="Variant" />
<argument index="0" name="key" type="Variant" />
<argument index="1" name="default" type="Variant" default="null" />
<description>
Gets a value and ensures the key is set. If the [code]key[/code] exists in the dictionary, this behaves like [method get]. Otherwise, the [code]default[/code] value is inserted into the dictionary and returned.
</description>
</method>
<method name="has">
<return type="bool" />
<argument index="0" name="key" type="Variant" />