Open TheColorRed opened 11 months ago
Array(int)
- Add ability to pass a number which would initiate an empty array filled withnull
for each value.
Already covered by:
Some previous discussion about chaining: https://github.com/godotengine/godot-proposals/discussions/4025
Describe the project you are working on
Game
Describe the problem or limitation you are having in your project
I like chaining array functions, so it would be helpful if more of the functions returned the changed array instead of void, also functions that already return something could have a sibling function that returns the array (not all functions this works for though).
Describe the feature / enhancement and how it helps to overcome the problem or limitation
In many cases, all that really would need to be done is return the reference to the array instead of returning
void
, and/or add an additional function that returns the reference.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Here are some examples that are not possible (examples are stupefied for example purposes):
Here is an example of something I actually wanted to do which I had to use more lines because I couldn't concat:
List of proposed changes:
Array(int)
- Add ability to pass a number which would initiate an empty array filled withnull
for each value..concat(Array, [...Array])
- Same asappend_array()
, only it returns a new array with the combination of all arrays passed to it (not a reference to the original)..fill(Variant)
- Returns a reference to the array (currently returns void)..reverse()
- Returns a reference to the array (currently returns void).If this enhancement will not be used often, can it be worked around with a few lines of script?
Yeah, it just adds additional lines code at times. This just feels cleaner to me.
Is there a reason why this should be core and not an add-on in the asset library?
It modifies the array API of GDScript.