ReferenceDevices

Array Add Remove

Student can grow, shrink, and rebuild arrays (concat, slice-around-index) to maintain a live roster.

Updated
Watch the Knot — array_add_remove in ~90 seconds.

Your pirate crew is boarding the skiff at the sea-stacks, but the roster needs to update live as they join and jump ship.

Arrays in Verse are fixed, so to grow or shrink your Roster, you rebuild it by concatenating new members or slicing around the ones leaving.

We start with the Cap'n and Mate, concatenate the new recruits to the end, then slice the array to drop the Gunner's index when they leave.

Reach for Concatenate and slicing whenever you need to maintain a live, changing list of players or loot.

var Roster:[]string = array{"Cap'n", "Mate"}
set Roster = Concatenate(array{Roster, array{"Gunner", "Cook"}})
set Roster = Concatenate(array{Roster[0..1], Roster[3..3]})

Build your own lesson with array_add_remove

Generate a personalized, compile-checked lesson grounded in this exact reference.

Build a lesson →