渲染zh-Hant

空

Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.

Represents the null value and can prefix a null check.

Syntax: 無 [<expression>]

Category#

literal

Examples#

radix/corpus/literalia/nihil.fab (canonical · keyword)#

Null literal and nullable union bindings.

# =============================================================================
# 無 — Null literal and nullable union bindings.
# =============================================================================
#
# What this teaches:
#   • the `無` literal — represents absence of a value (null)
#   • nullable union types with `∪` — `T ∪ 無` for values that may be absent
#   • null checks with `est 無` and `非 est 無`
#
# Common mistakes:
#   • Using 無 without declaring the type as T ∪ 無 — 無 requires a nullable union type.
#
# See also: ∪, 可選, 無
# =============================================================================

# literalia/nihil — 無 literal and T ∪ 無
#
# GRAMMAR:
#   literal :← '無'
#   unionType :← type '∪' '無'
#
# EXPECTED OUTPUT:
#   無, 真, 42
#
# BACKEND:
#   Cross-ref 無/nihil.fab.

fn maybe() → int ∪ none {
    return 42
}

main {
    const int ∪ none absent ← null
    print absent
    const bool nihilne ← absent is none
    print nihilne
    print maybe() not is none
}

Expected output:

nihil
verum
verum

radix/corpus/nihil/nihil.fab (canonical · keyword)#

Represents the null value and can prefix a null check.

# =============================================================================
# 無 — Represents the null value and can prefix a null check.
# =============================================================================
#
# What this teaches:
#   • the `無` keyword — used for null/none values
#
# Common mistakes:
#   • Using 無 without ∪ in the type position — nullable types must be declared as T ∪ 無.
#
# See also: ∪, 可選
# =============================================================================

# 無 — null literal
#
# GRAMMAR:
#   literal :← '無'
#
# EXPECTED OUTPUT:
#   Scalar stdout smoke (see body).
#

main {
    const none nothing ← null
    print nothing
}

Expected output:

nihil