diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-09 18:06:48 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-09 18:06:48 +0100 |
commit | 907298d673723d7d957c382647dedde66c29ecd2 (patch) | |
tree | 62537ac5e18b24834e8231a57a73e20ea4ec1535 /modules/gdscript/tests/scripts/runtime/features/dictionary_string_stringname_equivalent.gd | |
parent | 597e0c0fb9c4bd725dae1fca75875ec4c936079f (diff) | |
parent | e79be6ce07ed8c89011f759ecade070a3bd5a806 (diff) | |
download | redot-engine-907298d673723d7d957c382647dedde66c29ecd2.tar.gz |
Merge pull request #68747 from rune-scape/rune-stringname-unification
GDScript: Unify StringName and String
Diffstat (limited to 'modules/gdscript/tests/scripts/runtime/features/dictionary_string_stringname_equivalent.gd')
-rw-r--r-- | modules/gdscript/tests/scripts/runtime/features/dictionary_string_stringname_equivalent.gd | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/runtime/features/dictionary_string_stringname_equivalent.gd b/modules/gdscript/tests/scripts/runtime/features/dictionary_string_stringname_equivalent.gd new file mode 100644 index 0000000000..1f15026f17 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/dictionary_string_stringname_equivalent.gd @@ -0,0 +1,17 @@ +# https://github.com/godotengine/godot/issues/62957 + +func test(): + var string_dict = {} + string_dict["abc"] = 42 + var stringname_dict = {} + 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 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. + print("String Dictionary == StringName Dictionary: ", string_dict == stringname_dict) |