classes/class_array #251
Replies: 6 comments 7 replies
-
|
The documentation example of sort_custom's behavior is inaccurate - it reads (in part): # Sort descending, using a lambda function.
my_items.sort_custom(func(a, b): return a[0] > b[0])
print(my_items) # Prints [["Apple", 9], ["Tomato", 5], ["Rice", 4]]It should instead read: # Sort descending, using a lambda function.
my_items.sort_custom(func(a, b): return a[0] > b[0])
print(my_items) # Prints [["Tomato", 5], ["Rice", 4], ["Apple", 9]]Tested on Godot 4.3 |
Beta Was this translation helpful? Give feedback.
-
|
The example in the slice method's description is inaccurate, on reverse slicing: var letters = ["A", "B", "C", "D", "E", "F"]
print(letters.slice(2, -2)) # Prints ["C", "D"]
print(letters.slice(4, 1, -1)) # Prints ["E", "D", "C"]Correct output: print(letters.slice(2, -2)) # Prints ["C", "D", "E"]
print(letters.slice(4, 1, -1)) # Prints ["E", "D", "C", "B"]It's actually inclusive with the negative step. |
Beta Was this translation helpful? Give feedback.
-
|
Just stumbled upon this, the docs for the |
Beta Was this translation helpful? Give feedback.
-
|
In the Godot 4 game engine documentation, the description for the array append function has a mistake in the variable name. It should be "numbers" but it is incorrectly written as "nums." |
Beta Was this translation helpful? Give feedback.
-
|
Note: Arrays marked const in GDScript will give a constant pointer to the given array, rather than making the array itself a constant. Immutable arrays are apparently not a thing. https://godotforums.org/d/23252-array-typed-as-const-is-not-constant |
Beta Was this translation helpful? Give feedback.
-
|
About sort_custom (https://docs.godotengine.org/en/stable/classes/class_array.html#class-array-method-sort-custom) how are we supposed to deal when "a" & "b" share the same priority (for instance, when a & b are equals)? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
classes/class_array
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 Variant type. Elements are accessed by a numerical i...
https://docs.godotengine.org/en/stable/classes/class_array.html
Beta Was this translation helpful? Give feedback.
All reactions