否則
Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.
Runs the fallback branch when preceding conditional branches do not match.
Aliases: else, otherwise
Syntax: 否則 <block>
Category#
control-flow
Related#
Examples#
radix/corpus/secus/secus.fab (canonical · keyword)#
Runs the fallback branch when preceding conditional branches do not match.
# =============================================================================
# 否則 — Runs the fallback branch when preceding conditional branches do not
# match.
# =============================================================================
#
# What this teaches:
# • Conditional fallback — `否則` provides the else/otherwise branch that
# runs when no preceding `若` or `否則若` condition matched
# • Always comes last in an if-else chain; takes a block body
#
# Common mistakes:
# • Writing `否則 若` instead of the canonical `否則若` for else-if branches — `否則` must always be final.
#
# See also: 若, 否則若
# =============================================================================
# 否則 — final else branch
#
# GRAMMAR:
# elseClause :← '否則' block
#
# EXPECTED OUTPUT:
# Scalar stdout smoke (see body).
#
# BACKEND:
# Cross-ref: 若/secus.fab.
#
main {
const int hour ← 23
if hour ≺ 12 {
print "morning"
}
else {
print "afternoon-or-later"
}
}Expected output:
afternoon-or-later
radix/corpus/si/secus.fab (canonical · keyword)#
Runs the fallback branch when preceding conditional branches do not match.
# =============================================================================
# 否則 — Runs the fallback branch when preceding conditional branches do not
# match.
# =============================================================================
#
# What this teaches:
# • If-else branches — `若 { } 否則 { }` provides two-way branching; exactly
# one arm executes
# • `否則若` chains additional conditions before the final `否則` fallback;
# first match wins
#
# Common mistakes:
# • TODO: placing `否則` before a `否則若` branch — `否則` must always be the
# final clause
#
# See also: 若, 否則若
# =============================================================================
# si-secus (if-else) conditionals
#
# 若 <condition> { <body> } -- two-way branch
# 否則 { <body> }
# 若 <cond1> { } -- else-if chain
# 否則若 <cond2> { }
# 否則 { }
#
# GRAMMAR:
# ifStmt :← '若' expr block ('否則若' expr block)* ('否則' block)?
#
# EXPECTED OUTPUT:
# Grade and weather messages for sample scores and temperatures.
main {
# Two-way branch: exactly one arm runs
const int puncta ← 85
if puncta ≥ 90 {
print "gradus: A"
}
else {
# 85 < 90 → this arm
print "gradus: B aut minor"
}
# Each branch may contain several statements
const int calor ← 22
if calor ≻ 30 {
print "calidum"
print "aquam bibe"
}
else {
# 22 ≤ 30
print "commodum"
print "caelum mite"
}
# 否則若 chains additional tests; first match wins (75 → C)
const int gradus ← 75
if gradus ≥ 90 {
print "A - optimum"
}
elif gradus ≥ 80 {
print "B - bonum"
}
elif gradus ≥ 70 {
print "C - satis"
}
elif gradus ≥ 60 {
print "D - transit"
}
else {
print "F - deficit"
}
}Expected output:
gradus: B aut minor
commodum
caelum mite
C - satis