Our first example demonstrates the use of arrays in UnrealScript. In UnrealScript, an array is a collection of elements of a specific type.
Note that arrays in UnrealScript are typically printed in the form (Elements=(1,2,3)) when using the @ operator for string concatenation.
To run this example, you would typically place this code in a script file (e.g., ArrayExample.uc) within your UnrealScript project, compile it, and then call the RunExample() function from elsewhere in your game code or through the UnrealScript console.
UnrealScript’s array handling is somewhat different from many other languages:
Arrays are dynamic by default, meaning they can grow or shrink as needed.
The Length property is used both to get the current length and to set a new length.
There’s no built-in way to initialize an array with a specific size and values in one line, so we have to do it in steps.
Multi-dimensional arrays are created as arrays of arrays.
This example demonstrates basic array operations in UnrealScript, including creation, initialization, accessing elements, and working with multi-dimensional arrays.