Examples · learn/02-values · 66 of 339
format
tin run examples/learn/02-values/format.tinfn main() {
let price = 3.14159
print("price: {price:.2}") // 2 decimals
print("[{7:>4}] [{7:04}] [{"ok":<4}]") // a width, zeros, left-aligned
let rows = [("tea", 2.5), ("coffee", 13.0)]
for r in rows {
print("{r.0:<8}{r.1:>7.2}") // a little table
}
}