Dictionary.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Dictionary" category="Built-In Types" version="3.2">
  3. <brief_description>
  4. Dictionary type.
  5. </brief_description>
  6. <description>
  7. Dictionary type. Associative container which contains values referenced by unique keys. Dictionaries are always passed by reference.
  8. Erasing elements while iterating over them [b]is not supported[/b].
  9. Creating a dictionary:
  10. [codeblock]
  11. var d = {4: 5, "A key": "A value", 28: [1, 2, 3]}
  12. [/codeblock]
  13. To add a key to an existing dictionary, access it like an existing key and assign to it:
  14. [codeblock]
  15. d[4] = "hello" # Add integer 4 as a key and assign the String "hello" as its value.
  16. d["Godot"] = 3.01 # Add String "Godot" as a key and assign the value 3.01 to it.
  17. [/codeblock]
  18. </description>
  19. <tutorials>
  20. <link>https://docs.godotengine.org/en/latest/getting_started/scripting/gdscript/gdscript_basics.html#dictionary</link>
  21. </tutorials>
  22. <methods>
  23. <method name="clear">
  24. <description>
  25. Clear the dictionary, removing all key/value pairs.
  26. </description>
  27. </method>
  28. <method name="duplicate">
  29. <return type="Dictionary">
  30. </return>
  31. <argument index="0" name="deep" type="bool" default="False">
  32. </argument>
  33. <description>
  34. Creates a copy of the dictionary, and returns it.
  35. </description>
  36. </method>
  37. <method name="empty">
  38. <return type="bool">
  39. </return>
  40. <description>
  41. Returns [code]true[/code] if the dictionary is empty.
  42. </description>
  43. </method>
  44. <method name="erase">
  45. <return type="bool">
  46. </return>
  47. <argument index="0" name="key" type="Variant">
  48. </argument>
  49. <description>
  50. Erase a dictionary key/value pair by key. Returns [code]true[/code] if the given key was present in the dictionary, [code]false[/code] otherwise. Do not erase elements while iterating over the dictionary.
  51. </description>
  52. </method>
  53. <method name="get">
  54. <return type="Variant">
  55. </return>
  56. <argument index="0" name="key" type="Variant">
  57. </argument>
  58. <argument index="1" name="default" type="Variant" default="Null">
  59. </argument>
  60. <description>
  61. Returns the current value for the specified key in the [Dictionary]. If the key does not exist, the method returns the value of the optional default argument, or Null if it is omitted.
  62. </description>
  63. </method>
  64. <method name="has">
  65. <return type="bool">
  66. </return>
  67. <argument index="0" name="key" type="Variant">
  68. </argument>
  69. <description>
  70. Returns [code]true[/code] if the dictionary has a given key.
  71. </description>
  72. </method>
  73. <method name="has_all">
  74. <return type="bool">
  75. </return>
  76. <argument index="0" name="keys" type="Array">
  77. </argument>
  78. <description>
  79. Returns [code]true[/code] if the dictionary has all of the keys in the given array.
  80. </description>
  81. </method>
  82. <method name="hash">
  83. <return type="int">
  84. </return>
  85. <description>
  86. Returns a hashed integer value representing the dictionary contents.
  87. </description>
  88. </method>
  89. <method name="keys">
  90. <return type="Array">
  91. </return>
  92. <description>
  93. Returns the list of keys in the [Dictionary].
  94. </description>
  95. </method>
  96. <method name="size">
  97. <return type="int">
  98. </return>
  99. <description>
  100. Returns the size of the dictionary (in pairs).
  101. </description>
  102. </method>
  103. <method name="values">
  104. <return type="Array">
  105. </return>
  106. <description>
  107. Returns the list of values in the [Dictionary].
  108. </description>
  109. </method>
  110. </methods>
  111. <constants>
  112. </constants>
  113. </class>