Tuples
A tuple groups a fixed number of values, possibly of different types. Select a slot with .0, .1, and so on, or destructure the whole value in a pattern.
Tuples are value types, so binding or passing one copies its slots. A one-element tuple needs a trailing comma: (value,).
fn main() {
let position = ("west", 3)
let (direction, steps) = position
println(direction)
println(steps)
}
Examples use the moon toolchain version shown beside each result.
Output & diagnostics
Expected: west 3
Ctrl/⌘+Enter runs the current lesson.