Open Kezarus-tech opened 3 days ago
Might want to consider the naming here - given the convention in other programming languages and variable_clone
being a thing in GameMaker, array_clone(source, deep = false)
might work better.
But I don't mind the concept of the function itself! Even if it may be solved with variable_clone(array, 1)
for shallow copy or variable_clone(array, 128)
for deep copy, sometimes having dedicated and more descriptive functions works for the better.
On that note, struct_clone(source, deep = false)
might be handy too!
I'll leave it here for more discussion.
If variable_clone already exists, I don't see why implement something like I suggested.
And, hmmm, I see that variable_clone can be a name too broad for readability, but not that much as GML isn't a strongly typed language. Well, I leave the closing of this to you guys, but I don't think there is a need for a duplicated function just for name sake.
I had no idea variable_clone
worked for arrays too. I think having an array_clone
would be great, especially if the docs for this proposed function make a note about variable_clone
. Even if the function itself doesn't get used, it could serve as a great signpost for people like me who didn't know any better.
A simple function to duplicate an array. Good when you need to do some computations, but don't want to mess up the original array.