Examples · learn/04-control · 97 of 339
if-value
tin run examples/learn/04-control/if-value.tinfn 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" }}.")
}