null
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Null literal and nullable union bindings.
Syntax: none
Category#
literal
Related#
Examples#
radix/corpus/reference/literal/nulla/nulla.fab (canonical · literal)#
Null literal and nullable union bindings.
# =============================================================================
# none — The null value and nullable union bindings.
# =============================================================================
#
# What this teaches:
# • the `null` value (la `null`) — the sole value of the `none` type (la `none`)
# • nullable union types with `∪` — `T ∪ none` (la `T ∪ none`) for values that may be absent
# • null checks with `is none` and `not is none` (la `est none` / `is not none`)
#
# Common mistakes:
# • Storing `null` without declaring the type as `T ∪ none` — the null value requires a nullable union type.
#
# See also: ∪, optional, none
# =============================================================================
# literalia/nihil — the null value and T ∪ none
#
# GRAMMAR:
# literal :← 'null'
# unionType :← type '∪' 'none'
#
# EXPECTED OUTPUT:
# none, true, 42
#
# BACKEND:
# Cross-ref none/nihil.fab.
fn maybe() → int ∪ none {
return 42
}
main {
let int ∪ none absent ← null
print absent
let bool nihilne ← absent is none
print nihilne
print maybe() not is none
}Expected output:
none
true
true