Add an optional default return value argument to Object.get()#80841
Add an optional default return value argument to Object.get()#80841nevarek wants to merge 1 commit intogodotengine:masterfrom
Conversation
27003d8 to
0ae3a7b
Compare
|
Oh shoot I forgot about tests, I'll update those in the near future |
|
Needs compatibility methods and info added as this changes the API, there are also tests that need to be updated which use the original syntax I'm unsure if changing the method in c++ is the right way to go, instead of adding a bind method to handle that, it affects the entire codebase in a significant way, not sure why the c++ side needs to change |
| Variant Object::get(const StringName &p_name, const Variant &p_default_value) const { | ||
| bool is_defined = false; | ||
| const Variant result = get_or_null(p_name, &is_defined); | ||
| if (result.is_null() and !is_defined) { |
There was a problem hiding this comment.
| if (result.is_null() and !is_defined) { | |
| if (result.is_null() && !is_defined) { |
|
Right, this seems to be making too many changes... |
|
@AThousandShips and @KoBeWi, I came across this PR after hitting the inconsistency between Would y'all accept updating only Also @KoBeWi , your comment seemed non-committal on whether any change to the |
|
Changing the binding also affects C# and GDExtension. It might at least require a compatibility method.
Yeah. If modifying |
@KoBeWi Can you point me at an existing compatibility method? I don’t know the term. |
|
Hey, following up on this. This looks like a simple change, but I still don't have any context for what a "compatibility method" is in the godot source. Could you link an existing one, or just give me the name of one, and I can sort it out from there. |
Dictionary.get() in GDScript supports a second argument that is the value to return if the key does not exist in the Dictionary. This commit adds that behavior to Object.get() in GDScript. Supercedes godotengine#80841 Closes godot-proposals#3841
Dictionary.get() in GDScript supports a second argument that is the value to return if the key does not exist in the Dictionary. This commit adds that behavior to Object.get() in GDScript. Supercedes godotengine#80841 Closes godot-proposals#3841
Dictionary.get() in GDScript supports a second argument that is the value to return if the key does not exist in the Dictionary. This commit adds that behavior to Object.get() in GDScript. Supercedes godotengine#80841 Closes godot-proposals#3841
Dictionary.get() in GDScript supports a second argument that is the value to return if the key does not exist in the Dictionary. This commit adds that behavior to Object.get() in GDScript. Supercedes godotengine#80841 Closes godot-proposals#3841
Dictionary.get() in GDScript supports a second argument that is the value to return if the key does not exist in the Dictionary. This commit adds that behavior to Object.get() in GDScript. Supercedes godotengine#80841 Closes godot-proposals#3841
Implements feature request mentioned here godotengine/godot-proposals#3841
Production edit: Closes godotengine/godot-proposals#3841