Arrays, tuples, and ranges
Construct collections and grouped values, index them, slice them, and take tuples apart.
On this page
A patrol can keep points in an array, a contact scan can read one element, and a helper can return two related values as a tuple. These shapes keep several values together without hiding how they are used.
The problem
Section titled “The problem”Collection code has details that matter. matrix[row, column] is not the same shape as matrix[row][column]. ^1 counts from the end. A tuple element may be read by a written name or by Item1.
When to reach for it
Section titled “When to reach for it”Use an array construction when you need a fixed sequence of values. Use a struct construction when a value type has named constructor arguments. Use an indexer to read or write an element. Use a range and slice to select a span. Use a tuple to carry several results without declaring a new type, and deconstruct it when each element needs a local name.
To give a field or local an array type, open its type row in the Variables rail. array sits at the top of the type chooser, after var for a local. Choosing it reopens the chooser to ask what the array holds, so the row becomes int[] or Vector2[]. An array of arrays is not offered this way.
See it
Section titled “See it”The canvas presents each element or constructor argument as a pin. Index, range, from-end, slice, Make Tuple, and Break Tuple nodes keep their own shape when source is parsed back.
- Right-click empty canvas and choose the array, struct, Make Tuple, or Break Tuple action you need.
- For a new array, fill an element slot. Its type settles the array’s element type. Add, remove, or reorder slots to change the collection shape.
- For a struct, choose its type and constructor, then fill the argument pins.
- Place an element access and connect the collection plus its index. Choose add index to create another operand for a multi-dimensional access.
- Use a from-end index for positions such as the last element. The operand remains significant even when it is zero.
- Build a range with a start, an end, or deliberately open ends, then connect it to a slice.
- A Make Tuple starts with two slots. Fill both, then choose add pin for another. A named tuple and unnamed tuple with the same ordered element types can connect.
- Connect a tuple to Break Tuple to create a deconstruction. The resulting locals follow the tuple names where available.
- Press Compile in the toolbar, then inspect the re-parsed nodes. Author-written array and tuple spellings are retained when their recorded shape has not changed.
What it writes
Section titled “What it writes”When it goes wrong
Section titled “When it goes wrong”When it goes wrong
| Symptom | Check | Fix |
|---|---|---|
| The array stays wildcard gray | Check whether any slot has a typed value or wire. | Supply the first element so the array type can settle. |
| Compile leaves an access unfinished | Look for a missing collection, index, range, or assignment value. | Fill every required pin or remove the unfinished node. |
| A nested deconstruction refuses | Look for a tuple pattern inside another tuple pattern. | Finish that edit in C#; the parser flattens that shape. |