Skip to content
beskid The Beskid Book

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

07.3 Option and nullability

Option T is the only optional surface, no null, no optional keyword.

Option and nullability

If you type null expecting sympathy, you will receive diagnostics instead.

Optional presence must use Option<T> (corelib Core.Optional.Option) or an explicit enum with a dedicated absent variant at API boundaries.

  • Forbidden: null, optional keyword, ?T sugar
  • Present / absent: Option<T>::Some(x) / Option<T>::None (exact constructors per corelib)

null made billion-dollar bugs feel normal. Beskid chooses explicit enums so absence shows up in match, not in a surprise NRE at runtime.

Use match on options (see enums and match). Calling methods on a maybe-absent value without narrowing is a compile error, not a Friday production mystery.

classDiagram
accTitle: Option as an enumeration
accDescr: Option of T is an enumeration with the variants Some and None, and a match on it handles both.
class Option~T~ {
<<enumeration>>
Some(T)
None
}
class MatchExpression {
handles None as absent
handles Some as inner T
}
MatchExpression ..> Option : narrows

Text equivalent: Option<T> is an enumeration with variants Some(T) and None. A match narrows it, handling the absent case and using the inner T in the present case.

Functions and methods