classref: Sync with current master branch (cb7cd81)

This commit is contained in:
Godot Organization
2025-10-11 03:22:24 +00:00
parent c7cfd7f3a9
commit 9afaf48fc7
119 changed files with 6335 additions and 543 deletions
+9 -1
View File
@@ -17,7 +17,7 @@ A built-in data structure that holds a sequence of elements.
Description
-----------
An array data structure that can contain a sequence of elements of any :ref:`Variant<class_Variant>` type. Elements are accessed by a numerical index starting at ``0``. Negative indices are used to count from the back (``-1`` is the last element, ``-2`` is the second to last, etc.).
An array data structure that can contain a sequence of elements of any :ref:`Variant<class_Variant>` type by default. Values can optionally be constrained to a specific type by creating a *typed array*. Elements are accessed by a numerical index starting at ``0``. Negative indices are used to count from the back (``-1`` is the last element, ``-2`` is the second to last, etc.).
.. tabs::
@@ -33,6 +33,10 @@ An array data structure that can contain a sequence of elements of any :ref:`Var
print(array[1]) # Prints "Second"
print(array[-3]) # Prints "Second"
# This typed array can only contain integers.
# Attempting to add any other type will result in an error.
var typed_array: Array[int] = [1, 2, 3]
.. code-tab:: csharp
Godot.Collections.Array array = ["First", 2, 3, "Last"];
@@ -44,6 +48,10 @@ An array data structure that can contain a sequence of elements of any :ref:`Var
GD.Print(array[1]); // Prints "Second"
GD.Print(array[^3]); // Prints "Second"
// This typed array can only contain integers.
// Attempting to add any other type will result in an error.
Godot.Collections.Array<int> typedArray = [1, 2, 3];
\ **Note:** Arrays are always passed by **reference**. To get a copy of an array that can be modified independently of the original array, use :ref:`duplicate()<class_Array_method_duplicate>`.