mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
22 lines
345 B
XML
22 lines
345 B
XML
// Test return value of if expressions.
|
|
// Ref: false
|
|
|
|
---
|
|
{
|
|
let x = 1
|
|
let y = 2
|
|
let z
|
|
|
|
// Returns if branch.
|
|
z = if x < y { "ok" }
|
|
test(z, "ok")
|
|
|
|
// Returns else branch.
|
|
z = if x > y { "bad" } else { "ok" }
|
|
test(z, "ok")
|
|
|
|
// Missing else evaluates to none.
|
|
z = if x > y { "bad" }
|
|
test(z, none)
|
|
}
|