Tin

Examples · learn/04-control · 97 of 339

if-value

examples/learn/04-control/if-value.tintin run examples/learn/04-control/if-value.tin
fn main() {
  let stock = 0
  // with an else, if is an expression: it has a value
  let label = if stock == 0 { "sold out" } else { "{stock} left" }
  print(label)
  print("We have {if stock > 0 { "some" } else { "none" }}.")
}