Arrays in GDScript
Our first example demonstrates the use of arrays in GDScript. In GDScript, an array is a collection of elements that can be of any type.
Note that arrays in GDScript are printed in the form [v1, v2, v3, ...]
when using the print()
function.
When you run this script in Godot, you should see output similar to the following in the output panel:
This example demonstrates the basic operations and concepts of arrays in GDScript. Unlike statically-typed languages, GDScript arrays are dynamically-sized and can hold elements of different types. The syntax for creating, accessing, and modifying arrays is straightforward and flexible, making them a powerful tool for organizing and manipulating data in your Godot projects.