mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
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:
@@ -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" />
|
||||
|
||||
Reference in New Issue
Block a user