Use T? when a value may be missing and that absence is normal.
nickname String? = none
A normal String can be used where String? is expected.
Inspect a present value with is |name|:
display_name = if nickname is |name| then name else "guest"
Use postfix ? inside a function that also returns an optional value:
get_display_name |id String| -> String?:
user = find_user(id)?
return user.name
;
If find_user returns none, the current function returns none too.
T? is an optional value that may contain T or may be absent.
none is the only special absent value.
name String? = none
fallback String? = "guest"
Contextual wrapping
A value of T can be used where T? is expected.
none requires an immediate optional receiving context. It is not a standalone inferred type.
Optional values are not automatically unwrapped.
Present-value inspection
Inline inspection:
display_name = if maybe_name is |name| then name else "guest"
Block inspection:
display_name = if maybe_name is |name|:
then name
else
then "guest"
;
Statement inspection:
if maybe_name is none:
io.line("missing")
;
Full option match:
label = if maybe_name is:
"Priya" => then "Hi Priya"
|name| => then name
none => then "guest"
;
Option patterns support:
none- compatible literal present-value patterns
- compatible relational present-value patterns
|name| to capture any present value- guards
else =>
An option match can be exhaustive without else => when it has both an unguarded none arm and an unguarded present-value capture.
Direct fallback syntax such as maybe_name else then "guest" is invalid.
Absence inspection
Statement if can test for absence:
if maybe_name is none:
io.line("missing")
;
Equality and ordering
Options support equality comparisons:
present = maybe_name is "Priya"
absent = maybe_name is none
same = a is b
Two options can be compared only when they have the same option type and their inner type supports equality. Two absent values compare equal. Present values compare through the inner type's equality rule, and a present value never equals none.
Ordering operators such as < on optional values are not supported.
Postfix propagation
Postfix ? unwraps a present value or returns none from the enclosing function.
get_display_name |id String| -> String?:
user = find_user(id)?
return user.name
;
The exact contract is:
- the operand must be optional
- the enclosing function must have exactly one success return slot
- that success slot must be a compatible optional type
- the present payload becomes the expression result
- absence returns
none immediately ? cannot be followed by catch
Options are compiler-owned value shapes. Source code does not construct public Option variants.