Skip to content
ffredyk edited this page Jul 23, 2026 · 1 revision

resize

Category

Array

Arity

Binary<array> resize <newSize>.

<array> resize <number>

Description

Changes the size of the array to the given value. If the new size is larger, new slots are filled with nil. If smaller, elements beyond the new size are truncated. No return value (void).

How It Works

  • Growing: adds nil values until the list reaches the target size.
  • Shrinking: removes elements from the end via RemoveRange.
  • Same size: no-op.

Usage

Pre-allocate array

_arr = [];
_arr resize 10;                // _arr is [nil,nil,nil,nil,nil,nil,nil,nil,nil,nil]
// Now use set to assign:
_arr set [0, "first"];
_arr set [9, "last"];

Shrink array

_arr = [1, 2, 3, 4, 5];
_arr resize 2;                 // _arr is [1, 2] (3,4,5 discarded)

Clear array

_arr resize 0;                 // _arr is [] (empty)

Grow with existing data

_arr = [1, 2, 3];
_arr resize 5;                 // _arr is [1, 2, 3, nil, nil]
_arr set [4, 99];              // _arr is [1, 2, 3, nil, 99]

Thread Safety

Not thread-safe. Array must belong to the current scheduler.

See Also

SQ# Wiki

Home

Engine Docs

Migration

Commands

Value Constructors

Arithmetic

Comparison

Logic

Array

String

Math

Random

Type & Introspection

HashMap

Code Execution

Concurrency

Scheduler

Thread Safety

Error

Output

Time

Multiplayer

Compiler

Clone this wiki locally