可選
Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.
Marks a named declaration slot (parameter or 類型 field) as voluntary — the caller or provider may omit the value.
Aliases: optional, voluntary
Syntax: <type> <name> 可選 [= default | 或取 default]
Category#
declaration
Related#
Examples#
radix/corpus/sponte/sponte.fab (canonical · keyword)#
Marks a named declaration slot (parameter or 類型 field) as voluntary — the caller or provider may omit the value.
# =============================================================================
# 可選 — Marks a named declaration slot (parameter or 類型 field) as voluntary — the caller or provider may omit the value.
# =============================================================================
#
# What this teaches:
# • Voluntary parameter syntax — using `可選` to mark function parameters or 類型 fields as optional
# • Default values — combining `可選` with `vel` to provide fallbacks when the value is omitted
#
# Common mistakes:
# • confusing 可選 (optional parameter with a default) with ∪ 無 (nullable type) — 可選 marks omission, ∪ 無 marks absence
#
# See also: vel, 無, ∪, 函式, 類型
# =============================================================================
# 可選 — optional parameter / field marker
#
# GRAMMAR:
# optionalMarker :← '可選'
#
# EXPECTED OUTPUT:
# No 入口 — declaration or test-runner surface only.
#
# BACKEND:
# declaration-only optional slots (whitelist: 可選/sponte.fab). Cross-ref: optionalis/optionalis.fab.
#
fn greet(string 名稱, string titulus optional) → string {
return 名稱
}
fn paginate(int pagina optional coalesce 1) → string {
return "page"
}
class User {
var string name
var string email optional
}