默认
Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans 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