Tin

Examples · learn/02-values · 66 of 339

format

examples/learn/02-values/format.tintin run examples/learn/02-values/format.tin
fn 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
  }
}