@@ -979,6 +979,33 @@ assign to it::
979
979
this, use the :ref: `Object.get() <class_Object_method_get >` and
980
980
:ref: `Object.set() <class_Object_method_set >` methods instead.
981
981
982
+ Typed dictionaries
983
+ ^^^^^^^^^^^^^^^^^^
984
+
985
+ Godot 4.4 added support for typed dictionaries. On write operations, Godot checks that
986
+ element keys and values match the specified type, so the dictionary cannot contain invalid
987
+ keys or values. The GDScript static analyzer takes typed dictionaries into account. However,
988
+ dictionary methods that return values still have the ``Variant `` return type.
989
+
990
+ Typed dictionaries have the syntax ``Array[KeyType, ValueType] ``, where ``KeyType `` and ``ValueType ``
991
+ can be any ``Variant `` type, native or user class, or enum. Both the key and value type **must ** be specified,
992
+ but you can use ``Variant `` to make either of them untyped.
993
+ Nested dictionary types (like ``Dictionary[String, Dictionary[String, int]] ``)
994
+ are not supported.
995
+
996
+ ::
997
+
998
+ var a: Dictionary[String, int]
999
+ var b: Dictionary[String, Node]
1000
+ var c: Dictionary[Vector2i, MyClass]
1001
+ var d: Dictionary[MyEnum, float]
1002
+ # String keys, values can be any type.
1003
+ var e: Dictionary[String, Variant]
1004
+ # Keys can be any type, boolean values.
1005
+ var f: Dictionary[Variant, bool]
1006
+
1007
+ ``Dictionary `` and ``Dictionary[Variant, Variant] `` are the same thing.
1008
+
982
1009
:ref: `Signal <class_Signal >`
983
1010
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
984
1011
0 commit comments