Examples · learn/05-structs · 114 of 339
tuples
A tuple groups a few values without declaring a type.
tin run examples/learn/05-structs/tuples.tin// A tuple groups a few values without declaring a type.
fn minMax(a: int, b: int): (int, int) {
if a < b { (a, b) } else { (b, a) }
}
fn main() {
let pair = minMax(9, 4)
print(pair)
print(pair.0) // items by position: .0, .1, ...
let (low, high) = minMax(9, 4) // or name them all at once
print("{low} to {high}")
}