ReferenceVerse

Immutable Array Iteration

immutable array iteration

Updated
Watch the Knot — immutable-array-iteration in ~90 seconds.

When the Golden Hour event hits the Grotto Vault, every chest's loot instantly doubles, but the original stash stays perfectly untouched.

Since Verse arrays are locked in stone, we can't just edit the numbers; instead, we stream the old list through a loop that builds a brand new, upgraded array.

We set up our base Loot, then use a for-expression to pull each Coin out, multiply it, and automatically pack the results into a fresh Bonus array.

Reach for this pattern whenever you need to transform a list of items or scores into a new snapshot without mutating your original game state.

Loot := array{10, 20, 50}
Bonus := for (Coin : Loot):
    Coin * 2

Build your own lesson with immutable-array-iteration

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

Build a lesson →