mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Allow returning Dictionary after merging
This commit is contained in:
@@ -340,6 +340,24 @@
|
||||
[b]Note:[/b] [method merge] is [i]not[/i] recursive. Nested dictionaries are considered as keys that can be overwritten or not depending on the value of [param overwrite], but they will never be merged together.
|
||||
</description>
|
||||
</method>
|
||||
<method name="merged" qualifiers="const">
|
||||
<return type="Dictionary" />
|
||||
<param index="0" name="dictionary" type="Dictionary" />
|
||||
<param index="1" name="overwrite" type="bool" default="false" />
|
||||
<description>
|
||||
Returns a copy of this dictionary merged with the other [param dictionary]. By default, duplicate keys are not copied over, unless [param overwrite] is [code]true[/code]. See also [method merge].
|
||||
This method is useful for quickly making dictionaries with default values:
|
||||
[codeblock]
|
||||
var base = { "fruit": "apple", "vegetable": "potato" }
|
||||
var extra = { "fruit": "orange", "dressing": "vinegar" }
|
||||
# Prints { "fruit": "orange", "vegetable": "potato", "dressing": "vinegar" }
|
||||
print(extra.merged(base))
|
||||
# Prints { "fruit": "apple", "vegetable": "potato", "dressing": "vinegar" }
|
||||
print(extra.merged(base, true))
|
||||
[/codeblock]
|
||||
See also [method merge].
|
||||
</description>
|
||||
</method>
|
||||
<method name="size" qualifiers="const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
|
||||
Reference in New Issue
Block a user