Sync classref with master branch (4.0 changes)

This commit is contained in:
Rémi Verschelde
2020-03-13 17:17:50 +01:00
parent 966fd002ed
commit 03d40ff29e
360 changed files with 17483 additions and 16479 deletions

View File

@@ -27,131 +27,155 @@ Generic array which can contain several elements of any type, accessible by a nu
array[2] = "Three"
print(array[-2]) # Three.
Arrays can be concatenated using the ``+`` operator:
::
var array1 = ["One", 2]
var array2 = [3, "Four"]
print(array1 + array2) # ["One", 2, 3, "Four"]
Arrays are always passed by reference.
Methods
-------
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PoolColorArray<class_PoolColorArray>` from **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PoolVector3Array<class_PoolVector3Array>` from **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` from **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PoolStringArray<class_PoolStringArray>` from **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PoolRealArray<class_PoolRealArray>` from **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PoolIntArray<class_PoolIntArray>` from **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PoolByteArray<class_PoolByteArray>` from **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`append<class_Array_method_append>` **(** :ref:`Variant<class_Variant>` value **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Variant<class_Variant>` | :ref:`back<class_Array_method_back>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`bsearch<class_Array_method_bsearch>` **(** :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` before=True **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`bsearch_custom<class_Array_method_bsearch_custom>` **(** :ref:`Variant<class_Variant>` value, :ref:`Object<class_Object>` obj, :ref:`String<class_String>` func, :ref:`bool<class_bool>` before=True **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`clear<class_Array_method_clear>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`count<class_Array_method_count>` **(** :ref:`Variant<class_Variant>` value **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`duplicate<class_Array_method_duplicate>` **(** :ref:`bool<class_bool>` deep=False **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`empty<class_Array_method_empty>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`erase<class_Array_method_erase>` **(** :ref:`Variant<class_Variant>` value **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`find<class_Array_method_find>` **(** :ref:`Variant<class_Variant>` what, :ref:`int<class_int>` from=0 **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`find_last<class_Array_method_find_last>` **(** :ref:`Variant<class_Variant>` value **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Variant<class_Variant>` | :ref:`front<class_Array_method_front>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`has<class_Array_method_has>` **(** :ref:`Variant<class_Variant>` value **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`hash<class_Array_method_hash>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`insert<class_Array_method_insert>` **(** :ref:`int<class_int>` position, :ref:`Variant<class_Variant>` value **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`invert<class_Array_method_invert>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Variant<class_Variant>` | :ref:`max<class_Array_method_max>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Variant<class_Variant>` | :ref:`min<class_Array_method_min>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Variant<class_Variant>` | :ref:`pop_back<class_Array_method_pop_back>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Variant<class_Variant>` | :ref:`pop_front<class_Array_method_pop_front>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`push_back<class_Array_method_push_back>` **(** :ref:`Variant<class_Variant>` value **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`push_front<class_Array_method_push_front>` **(** :ref:`Variant<class_Variant>` value **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`remove<class_Array_method_remove>` **(** :ref:`int<class_int>` position **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`resize<class_Array_method_resize>` **(** :ref:`int<class_int>` size **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`rfind<class_Array_method_rfind>` **(** :ref:`Variant<class_Variant>` what, :ref:`int<class_int>` from=-1 **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`shuffle<class_Array_method_shuffle>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`size<class_Array_method_size>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`slice<class_Array_method_slice>` **(** :ref:`int<class_int>` begin, :ref:`int<class_int>` end, :ref:`int<class_int>` step=1, :ref:`bool<class_bool>` deep=False **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`sort<class_Array_method_sort>` **(** **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`sort_custom<class_Array_method_sort_custom>` **(** :ref:`Object<class_Object>` obj, :ref:`String<class_String>` func **)** |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedColorArray<class_PackedColorArray>` from **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedVector3Array<class_PackedVector3Array>` from **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` from **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedStringArray<class_PackedStringArray>` from **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedFloat64Array<class_PackedFloat64Array>` from **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` from **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedInt64Array<class_PackedInt64Array>` from **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedInt32Array<class_PackedInt32Array>` from **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedByteArray<class_PackedByteArray>` from **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`append<class_Array_method_append>` **(** :ref:`Variant<class_Variant>` value **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`back<class_Array_method_back>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`bsearch<class_Array_method_bsearch>` **(** :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` before=true **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`bsearch_custom<class_Array_method_bsearch_custom>` **(** :ref:`Variant<class_Variant>` value, :ref:`Object<class_Object>` obj, :ref:`String<class_String>` func, :ref:`bool<class_bool>` before=true **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`clear<class_Array_method_clear>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`count<class_Array_method_count>` **(** :ref:`Variant<class_Variant>` value **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`duplicate<class_Array_method_duplicate>` **(** :ref:`bool<class_bool>` deep=false **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`empty<class_Array_method_empty>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`erase<class_Array_method_erase>` **(** :ref:`Variant<class_Variant>` value **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`find<class_Array_method_find>` **(** :ref:`Variant<class_Variant>` what, :ref:`int<class_int>` from=0 **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`find_last<class_Array_method_find_last>` **(** :ref:`Variant<class_Variant>` value **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`front<class_Array_method_front>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`has<class_Array_method_has>` **(** :ref:`Variant<class_Variant>` value **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`hash<class_Array_method_hash>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`insert<class_Array_method_insert>` **(** :ref:`int<class_int>` position, :ref:`Variant<class_Variant>` value **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`invert<class_Array_method_invert>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`max<class_Array_method_max>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`min<class_Array_method_min>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`pop_back<class_Array_method_pop_back>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`pop_front<class_Array_method_pop_front>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`push_back<class_Array_method_push_back>` **(** :ref:`Variant<class_Variant>` value **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`push_front<class_Array_method_push_front>` **(** :ref:`Variant<class_Variant>` value **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`remove<class_Array_method_remove>` **(** :ref:`int<class_int>` position **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`resize<class_Array_method_resize>` **(** :ref:`int<class_int>` size **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`rfind<class_Array_method_rfind>` **(** :ref:`Variant<class_Variant>` what, :ref:`int<class_int>` from=-1 **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`shuffle<class_Array_method_shuffle>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`size<class_Array_method_size>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`slice<class_Array_method_slice>` **(** :ref:`int<class_int>` begin, :ref:`int<class_int>` end, :ref:`int<class_int>` step=1, :ref:`bool<class_bool>` deep=false **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`sort<class_Array_method_sort>` **(** **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`sort_custom<class_Array_method_sort_custom>` **(** :ref:`Object<class_Object>` obj, :ref:`String<class_String>` func **)** |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Method Descriptions
-------------------
.. _class_Array_method_Array:
- :ref:`Array<class_Array>` **Array** **(** :ref:`PoolColorArray<class_PoolColorArray>` from **)**
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedColorArray<class_PackedColorArray>` from **)**
Constructs an array from a :ref:`PoolColorArray<class_PoolColorArray>`.
Constructs an array from a :ref:`PackedColorArray<class_PackedColorArray>`.
----
- :ref:`Array<class_Array>` **Array** **(** :ref:`PoolVector3Array<class_PoolVector3Array>` from **)**
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedVector3Array<class_PackedVector3Array>` from **)**
Constructs an array from a :ref:`PoolVector3Array<class_PoolVector3Array>`.
Constructs an array from a :ref:`PackedVector3Array<class_PackedVector3Array>`.
----
- :ref:`Array<class_Array>` **Array** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` from **)**
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` from **)**
Constructs an array from a :ref:`PoolVector2Array<class_PoolVector2Array>`.
Constructs an array from a :ref:`PackedVector2Array<class_PackedVector2Array>`.
----
- :ref:`Array<class_Array>` **Array** **(** :ref:`PoolStringArray<class_PoolStringArray>` from **)**
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedStringArray<class_PackedStringArray>` from **)**
Constructs an array from a :ref:`PoolStringArray<class_PoolStringArray>`.
Constructs an array from a :ref:`PackedStringArray<class_PackedStringArray>`.
----
- :ref:`Array<class_Array>` **Array** **(** :ref:`PoolRealArray<class_PoolRealArray>` from **)**
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedFloat64Array<class_PackedFloat64Array>` from **)**
Constructs an array from a :ref:`PoolRealArray<class_PoolRealArray>`.
Constructs an array from a :ref:`PackedFloat64Array<class_PackedFloat64Array>`.
----
- :ref:`Array<class_Array>` **Array** **(** :ref:`PoolIntArray<class_PoolIntArray>` from **)**
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` from **)**
Constructs an array from a :ref:`PoolIntArray<class_PoolIntArray>`.
Constructs an array from a :ref:`PackedFloat32Array<class_PackedFloat32Array>`.
----
- :ref:`Array<class_Array>` **Array** **(** :ref:`PoolByteArray<class_PoolByteArray>` from **)**
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedInt64Array<class_PackedInt64Array>` from **)**
Constructs an array from a :ref:`PoolByteArray<class_PoolByteArray>`.
Constructs an array from a :ref:`PackedInt64Array<class_PackedInt64Array>`.
----
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedInt32Array<class_PackedInt32Array>` from **)**
Constructs an array from a :ref:`PackedInt32Array<class_PackedInt32Array>`.
----
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedByteArray<class_PackedByteArray>` from **)**
Constructs an array from a :ref:`PackedByteArray<class_PackedByteArray>`.
----
@@ -165,7 +189,7 @@ Appends an element at the end of the array (alias of :ref:`push_back<class_Array
.. _class_Array_method_back:
- :ref:`Variant<class_Variant>` **back** **(** **)**
- void **back** **(** **)**
Returns the last element of the array, or ``null`` if the array is empty.
@@ -173,7 +197,7 @@ Returns the last element of the array, or ``null`` if the array is empty.
.. _class_Array_method_bsearch:
- :ref:`int<class_int>` **bsearch** **(** :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` before=True **)**
- :ref:`int<class_int>` **bsearch** **(** :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` before=true **)**
Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search. Optionally, a ``before`` specifier can be passed. If ``false``, the returned index comes after all existing entries of the value in the array.
@@ -183,7 +207,7 @@ Finds the index of an existing value (or the insertion index that maintains sort
.. _class_Array_method_bsearch_custom:
- :ref:`int<class_int>` **bsearch_custom** **(** :ref:`Variant<class_Variant>` value, :ref:`Object<class_Object>` obj, :ref:`String<class_String>` func, :ref:`bool<class_bool>` before=True **)**
- :ref:`int<class_int>` **bsearch_custom** **(** :ref:`Variant<class_Variant>` value, :ref:`Object<class_Object>` obj, :ref:`String<class_String>` func, :ref:`bool<class_bool>` before=true **)**
Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search and a custom comparison method. Optionally, a ``before`` specifier can be passed. If ``false``, the returned index comes after all existing entries of the value in the array. The custom method receives two arguments (an element from the array and the value searched for) and must return ``true`` if the first argument is less than the second, and return ``false`` otherwise.
@@ -209,7 +233,7 @@ Returns the number of times an element is in the array.
.. _class_Array_method_duplicate:
- :ref:`Array<class_Array>` **duplicate** **(** :ref:`bool<class_bool>` deep=False **)**
- :ref:`Array<class_Array>` **duplicate** **(** :ref:`bool<class_bool>` deep=false **)**
Returns a copy of the array.
@@ -251,7 +275,7 @@ Searches the array in reverse order for a value and returns its index or -1 if n
.. _class_Array_method_front:
- :ref:`Variant<class_Variant>` **front** **(** **)**
- void **front** **(** **)**
Returns the first element of the array, or ``null`` if the array is empty.
@@ -298,7 +322,7 @@ Reverses the order of the elements in the array.
.. _class_Array_method_max:
- :ref:`Variant<class_Variant>` **max** **(** **)**
- void **max** **(** **)**
Returns the maximum value contained in the array if all elements are of comparable types. If the elements can't be compared, ``null`` is returned.
@@ -306,7 +330,7 @@ Returns the maximum value contained in the array if all elements are of comparab
.. _class_Array_method_min:
- :ref:`Variant<class_Variant>` **min** **(** **)**
- void **min** **(** **)**
Returns the minimum value contained in the array if all elements are of comparable types. If the elements can't be compared, ``null`` is returned.
@@ -314,7 +338,7 @@ Returns the minimum value contained in the array if all elements are of comparab
.. _class_Array_method_pop_back:
- :ref:`Variant<class_Variant>` **pop_back** **(** **)**
- void **pop_back** **(** **)**
Removes and returns the last element of the array. Returns ``null`` if the array is empty.
@@ -322,7 +346,7 @@ Removes and returns the last element of the array. Returns ``null`` if the array
.. _class_Array_method_pop_front:
- :ref:`Variant<class_Variant>` **pop_front** **(** **)**
- void **pop_front** **(** **)**
Removes and returns the first element of the array. Returns ``null`` if the array is empty.
@@ -386,7 +410,7 @@ Returns the number of elements in the array.
.. _class_Array_method_slice:
- :ref:`Array<class_Array>` **slice** **(** :ref:`int<class_int>` begin, :ref:`int<class_int>` end, :ref:`int<class_int>` step=1, :ref:`bool<class_bool>` deep=False **)**
- :ref:`Array<class_Array>` **slice** **(** :ref:`int<class_int>` begin, :ref:`int<class_int>` end, :ref:`int<class_int>` step=1, :ref:`bool<class_bool>` deep=false **)**
Duplicates the subset described in the function and returns it in an array, deeply copying the array if ``deep`` is ``true``. Lower and upper index are inclusive, with the ``step`` describing the change between indices while slicing.
@@ -398,7 +422,13 @@ Duplicates the subset described in the function and returns it in an array, deep
Sorts the array.
**Note:** strings are sorted in alphabetical, not natural order.
**Note:** Strings are sorted in alphabetical order (as opposed to natural order). This may lead to unexpected behavior when sorting an array of strings ending with a sequence of numbers. Consider the following example:
::
var strings = ["string1", "string2", "string10", "string11"]
strings.sort()
print(strings) # Prints [string1, string10, string11, string2]
----