ReferenceVerse

Multiple Return Values

Return and destructure tuples for multi-value results.

Updated
Watch the Knot — multiple-return-values in ~90 seconds.

Your windmill just took a cannonball hit, and you need to know its exact health and spin speed all at once.

Instead of writing two separate functions, you can bundle both values into a single tuple and unpack them right where you need them.

We define GetMillStats to return a tuple of two integers, then destructure it into Health and Speed in one clean line inside OnBegin.

Reach for tuples when a single action naturally produces multiple pieces of game state.

windmill_device := class(creative_device):
    GetMillStats():tuple(int, int) =
        (100, 5)
    OnBegin<override>()<suspends>:void =
        (Health, Speed) := GetMillStats()
        Print("HP: {Health}, SPD: {Speed}")

Build your own lesson with multiple-return-values

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

Build a lesson →