Merge pull request #52090 from balloonpopper/bug52060

Correct null and boolean values being capitalised by the str command
This commit is contained in:
Max Hilbrunner 2021-08-27 21:05:47 +02:00 committed by GitHub
commit 4e67e9bca6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 93 additions and 82 deletions

View file

@ -13,15 +13,15 @@
[codeblocks]
[gdscript]
var n = Node2D.new()
print("position" in n) # Prints "True".
print("other_property" in n) # Prints "False".
print("position" in n) # Prints "true".
print("other_property" in n) # Prints "false".
[/gdscript]
[csharp]
var node = new Node2D();
// C# has no direct equivalent to GDScript's `in` operator here, but we
// can achieve the same behavior by performing `Get` with a null check.
GD.Print(node.Get("position") != null); // Prints "True".
GD.Print(node.Get("other_property") != null); // Prints "False".
GD.Print(node.Get("position") != null); // Prints "true".
GD.Print(node.Get("other_property") != null); // Prints "false".
[/csharp]
[/codeblocks]
The [code]in[/code] operator will evaluate to [code]true[/code] as long as the key exists, even if the value is [code]null[/code].