StringName Dictionary keys

also added 'is_string()' method to Variant
and refactored many String type comparisons to use it instead
This commit is contained in:
rune-scape
2023-12-28 14:44:23 -08:00
committed by rune-scape
parent 40b378e9e2
commit 154049ce17
34 changed files with 65 additions and 82 deletions

View File

@@ -15,5 +15,5 @@ GDTEST_OK
>> Line: 16
>> CONFUSABLE_CAPTURE_REASSIGNMENT
>> Reassigning lambda capture does not modify the outer local variable "array_assign".
lambda 2 2 12 (2, 0) [2] [2] { "x": 2 }
outer 2 1 1 (1, 0) [1] [2] { "x": 2 }
lambda 2 2 12 (2, 0) [2] [2] { &"x": 2 }
outer 2 1 1 (1, 0) [1] [2] { &"x": 2 }

View File

@@ -1,2 +1,2 @@
GDTEST_OK
{ "a": 1, "b": 2, "with spaces": 3, "2": 4 }
{ &"a": 1, &"b": 2, &"with spaces": 3, &"2": 4 }

View File

@@ -1,2 +1,2 @@
GDTEST_OK
{ "hello": { "world": { "is": "beautiful" } } }
{ "hello": { &"world": { "is": "beautiful" } } }

View File

@@ -7,11 +7,11 @@ func test():
stringname_dict[&"abc"] = 24
print("String key is TYPE_STRING: ", typeof(string_dict.keys()[0]) == TYPE_STRING)
print("StringName key is TYPE_STRING: ", typeof(stringname_dict.keys()[0]) == TYPE_STRING)
print("StringName key is TYPE_STRING_NAME: ", typeof(stringname_dict.keys()[0]) == TYPE_STRING_NAME)
print("StringName gets String: ", string_dict.get(&"abc"))
print("String gets StringName: ", stringname_dict.get("abc"))
stringname_dict[&"abc"] = 42
# They compare equal because StringName keys are converted to String.
# They compare equal because StringName keys are considered equivalent to String keys.
print("String Dictionary == StringName Dictionary: ", string_dict == stringname_dict)

View File

@@ -1,6 +1,6 @@
GDTEST_OK
String key is TYPE_STRING: true
StringName key is TYPE_STRING: true
StringName key is TYPE_STRING_NAME: true
StringName gets String: 42
String gets StringName: 24
String Dictionary == StringName Dictionary: true