Sfoglia il codice sorgente

Improve documentation related to Array error handling

This closes https://github.com/godotengine/godot-docs/issues/3834.

(cherry picked from commit 263f620421773e74a0d5c0306c1453883dc205bb)
Hugo Locurcio 5 anni fa
parent
commit
74952764f3
1 ha cambiato i file con 7 aggiunte e 5 eliminazioni
  1. 7 5
      doc/classes/Array.xml

+ 7 - 5
doc/classes/Array.xml

@@ -99,7 +99,8 @@
 			<return type="Variant">
 			</return>
 			<description>
-				Returns the last element of the array. Throws an error and returns [code]null[/code] if the array is empty.
+				Returns the last element of the array. Prints an error and returns [code]null[/code] if the array is empty.
+				[b]Note:[/b] Calling this function is not the same as writing [code]array[-1][/code]. If the array is empty, accessing by index will pause project execution when running from the editor.
 			</description>
 		</method>
 		<method name="bsearch">
@@ -192,7 +193,8 @@
 			<return type="Variant">
 			</return>
 			<description>
-				Returns the first element of the array. Throws an error and returns [code]null[/code] if the array is empty.
+				Returns the first element of the array. Prints an error and returns [code]null[/code] if the array is empty.
+				[b]Note:[/b] Calling this function is not the same as writing [code]array[0][/code]. If the array is empty, accessing by index will pause project execution when running from the editor.
 			</description>
 		</method>
 		<method name="has">
@@ -255,14 +257,14 @@
 			<return type="Variant">
 			</return>
 			<description>
-				Removes and returns the last element of the array. Returns [code]null[/code] if the array is empty.
+				Removes and returns the last element of the array. Returns [code]null[/code] if the array is empty, without printing an error message.
 			</description>
 		</method>
 		<method name="pop_front">
 			<return type="Variant">
 			</return>
 			<description>
-				Removes and returns the first element of the array. Returns [code]null[/code] if the array is empty.
+				Removes and returns the first element of the array. Returns [code]null[/code] if the array is empty, wwithout printing an error message.
 			</description>
 		</method>
 		<method name="push_back">
@@ -283,7 +285,7 @@
 			<argument index="0" name="position" type="int">
 			</argument>
 			<description>
-				Removes an element from the array by index.
+				Removes an element from the array by index. If the index does not exist in the array, nothing happens.
 			</description>
 		</method>
 		<method name="resize">