Named Tuple Elements
Access tuple elements by position and keep multi-value returns readable.
named-tuple-elements in ~90 seconds.The Windmill Bluff's harvest tracker just popped up '10 sacks of Flour'. It perfectly reads the exact count and item from a single bundle of mixed data.
We bundle that mixed data into one tuple to keep it organized. Then we unpack it by accessing each element's position with round brackets.
We define the tuple, then use zero-based indices like zero and one to pull out the integer, float, and string into clearly named variables.
Reach for tuples when a function returns multiple mixed values. Always assign them to named variables so your game logic stays crystal clear.
WindmillOutput := (10, 5.0, "Flour")
Sacks := WindmillOutput(0)
Weight := WindmillOutput(1)
Item := WindmillOutput(2)
Print("{Sacks} sacks of {Item}")
Build your own lesson with named-tuple-elements
Generate a personalized, compile-checked lesson grounded in this exact reference.
Build a lesson →