2
0
Эх сурвалжийг харах

Merge pull request #106369 from Calinou/doc-array-get

Improve documentation for `Array.get()` and `Packed*Array.get()` methods
Thaddeus Crews 3 сар өмнө
parent
commit
d7d6bc77ed

+ 2 - 1
doc/classes/Array.xml

@@ -435,7 +435,8 @@
 			<return type="Variant" />
 			<param index="0" name="index" type="int" />
 			<description>
-				Returns the element at the given [param index] in the array. This is the same as using the [code][][/code] operator ([code]array[index][/code]).
+				Returns the element at the given [param index] in the array. If [param index] out-of-bounds or negative, this method fails and returns [code]null[/code].
+				This method is similar (but not identical) to the [code][][/code] operator. Most notably, when this method fails, it doesn't pause project execution if run from the editor.
 			</description>
 		</method>
 		<method name="get_typed_builtin" qualifiers="const">

+ 2 - 1
doc/classes/PackedByteArray.xml

@@ -342,7 +342,8 @@
 			<return type="int" />
 			<param index="0" name="index" type="int" />
 			<description>
-				Returns the byte at the given [param index] in the array. This is the same as using the [code][][/code] operator ([code]array[index][/code]).
+				Returns the byte at the given [param index] in the array. If [param index] out-of-bounds or negative, this method fails and returns [code]0[/code].
+				This method is similar (but not identical) to the [code][][/code] operator. Most notably, when this method fails, it doesn't pause project execution if run from the editor.
 			</description>
 		</method>
 		<method name="get_string_from_ascii" qualifiers="const">

+ 2 - 1
doc/classes/PackedColorArray.xml

@@ -105,7 +105,8 @@
 			<return type="Color" />
 			<param index="0" name="index" type="int" />
 			<description>
-				Returns the [Color] at the given [param index] in the array. This is the same as using the [code][][/code] operator ([code]array[index][/code]).
+				Returns the [Color] at the given [param index] in the array. If [param index] out-of-bounds or negative, this method fails and returns [code]Color(0, 0, 0, 1)[/code].
+				This method is similar (but not identical) to the [code][][/code] operator. Most notably, when this method fails, it doesn't pause project execution if run from the editor.
 			</description>
 		</method>
 		<method name="has" qualifiers="const">

+ 2 - 1
doc/classes/PackedFloat32Array.xml

@@ -105,7 +105,8 @@
 			<return type="float" />
 			<param index="0" name="index" type="int" />
 			<description>
-				Returns the 32-bit float at the given [param index] in the array. This is the same as using the [code][][/code] operator ([code]array[index][/code]).
+				Returns the 32-bit float at the given [param index] in the array. If [param index] out-of-bounds or negative, this method fails and returns [code]0.0[/code].
+				This method is similar (but not identical) to the [code][][/code] operator. Most notably, when this method fails, it doesn't pause project execution if run from the editor.
 			</description>
 		</method>
 		<method name="has" qualifiers="const">

+ 2 - 1
doc/classes/PackedFloat64Array.xml

@@ -106,7 +106,8 @@
 			<return type="float" />
 			<param index="0" name="index" type="int" />
 			<description>
-				Returns the 64-bit float at the given [param index] in the array. This is the same as using the [code][][/code] operator ([code]array[index][/code]).
+				Returns the 64-bit float at the given [param index] in the array. If [param index] out-of-bounds or negative, this method fails and returns [code]0.0[/code].
+				This method is similar (but not identical) to the [code][][/code] operator. Most notably, when this method fails, it doesn't pause project execution if run from the editor.
 			</description>
 		</method>
 		<method name="has" qualifiers="const">

+ 2 - 1
doc/classes/PackedInt32Array.xml

@@ -101,7 +101,8 @@
 			<return type="int" />
 			<param index="0" name="index" type="int" />
 			<description>
-				Returns the 32-bit integer at the given [param index] in the array. This is the same as using the [code][][/code] operator ([code]array[index][/code]).
+				Returns the 32-bit integer at the given [param index] in the array. If [param index] out-of-bounds or negative, this method fails and returns [code]0[/code].
+				This method is similar (but not identical) to the [code][][/code] operator. Most notably, when this method fails, it doesn't pause project execution if run from the editor.
 			</description>
 		</method>
 		<method name="has" qualifiers="const">

+ 2 - 1
doc/classes/PackedInt64Array.xml

@@ -102,7 +102,8 @@
 			<return type="int" />
 			<param index="0" name="index" type="int" />
 			<description>
-				Returns the 64-bit integer at the given [param index] in the array. This is the same as using the [code][][/code] operator ([code]array[index][/code]).
+				Returns the 64-bit integer at the given [param index] in the array. If [param index] out-of-bounds or negative, this method fails and returns [code]0[/code].
+				This method is similar (but not identical) to the [code][][/code] operator. Most notably, when this method fails, it doesn't pause project execution if run from the editor.
 			</description>
 		</method>
 		<method name="has" qualifiers="const">

+ 2 - 1
doc/classes/PackedStringArray.xml

@@ -108,7 +108,8 @@
 			<return type="String" />
 			<param index="0" name="index" type="int" />
 			<description>
-				Returns the [String] at the given [param index] in the array. This is the same as using the [code][][/code] operator ([code]array[index][/code]).
+				Returns the [String] at the given [param index] in the array. Returns an empty string and prints an error if the access is out of bounds. Negative indices are not supported; they will always consider the value to be out of bounds and return an empty string.
+				This is similar to using the [code][][/code] operator ([code]array[index][/code]), except that operator supports negative indices and causes a debugger break if out-of-bounds access is performed.
 			</description>
 		</method>
 		<method name="has" qualifiers="const">

+ 2 - 1
doc/classes/PackedVector2Array.xml

@@ -110,7 +110,8 @@
 			<return type="Vector2" />
 			<param index="0" name="index" type="int" />
 			<description>
-				Returns the [Vector2] at the given [param index] in the array. This is the same as using the [code][][/code] operator ([code]array[index][/code]).
+				Returns the [Vector2] at the given [param index] in the array. If [param index] out-of-bounds or negative, this method fails and returns [code]Vector2(0, 0)[/code].
+				This method is similar (but not identical) to the [code][][/code] operator. Most notably, when this method fails, it doesn't pause project execution if run from the editor.
 			</description>
 		</method>
 		<method name="has" qualifiers="const">

+ 2 - 1
doc/classes/PackedVector3Array.xml

@@ -109,7 +109,8 @@
 			<return type="Vector3" />
 			<param index="0" name="index" type="int" />
 			<description>
-				Returns the [Vector3] at the given [param index] in the array. This is the same as using the [code][][/code] operator ([code]array[index][/code]).
+				Returns the [Vector3] at the given [param index] in the array. If [param index] out-of-bounds or negative, this method fails and returns [code]Vector3(0, 0, 0)[/code].
+				This method is similar (but not identical) to the [code][][/code] operator. Most notably, when this method fails, it doesn't pause project execution if run from the editor.
 			</description>
 		</method>
 		<method name="has" qualifiers="const">

+ 2 - 1
doc/classes/PackedVector4Array.xml

@@ -109,7 +109,8 @@
 			<return type="Vector4" />
 			<param index="0" name="index" type="int" />
 			<description>
-				Returns the [Vector4] at the given [param index] in the array. This is the same as using the [code][][/code] operator ([code]array[index][/code]).
+				Returns the [Vector4] at the given [param index] in the array. If [param index] out-of-bounds or negative, this method fails and returns [code]Vector4(0, 0, 0, 0)[/code].
+				This method is similar (but not identical) to the [code][][/code] operator. Most notably, when this method fails, it doesn't pause project execution if run from the editor.
 			</description>
 		</method>
 		<method name="has" qualifiers="const">