預設
Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.
Starts the default branch of an 選擇 or 比對 statement.
Aliases: default
Syntax: 預設 <block>
Category#
control-flow
Related#
Examples#
radix/corpus/ceterum/ceterum.fab (canonical · keyword)#
Starts the default branch of an 選擇 or 比對 statement.
# =============================================================================
# 預設 — Starts the default branch of an 選擇 or 比對 statement.
# =============================================================================
#
# What this teaches:
# • Default arm — `預設 <block>` is the catch-all branch in an `選擇`
# or `比對` match expression
# • Fallback handling — when no `分支` pattern matches, execution falls
# through to the `預設` block
#
# Common mistakes:
# • using `預設` with `比對 全部` — `全部` forbids catchall arms and requires listing every variant explicitly (SEM044)
#
# See also: 選擇, 比對
# =============================================================================
# 預設 — default 選擇 arm
#
# GRAMMAR:
# defaultClause :← '預設' block
#
# EXPECTED OUTPUT:
# Scalar stdout smoke (see body).
#
# BACKEND:
# Cross-ref: 選擇/ceterum.fab.
#
main {
const _ 標籤 ← "z"
switch 標籤 {
case "a" { print "a" }
default { print "default" }
}
}Expected output:
default