Confused about passing arrays as reference (Godot 4.1.1)

made a simple script to illustrate the issue. This is a global script and scene script:

problem

When I run the scene, the output is this:
[9,9,9,9,9]
[ ]

My question is that if setting one array equal to another creates a reference to the array, why is scene_array blank but global_array filled?

Because assigning to it creates a new reference

If you append to it you share the results

2 Likes

Ohhhhhhhhhhh

Thanks a lot!

1 Like