Skip to content

Modern Result Optional

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Result › Result › Optional

Optional

Holds one value or nothing at all; a new one is empty.

Syntax

Optional( of T )

Notes

  • "nothing is here"

Examples

#import "std/outcome"
using outcome

'' Optional is Result's smaller sibling: absence with no explanation.
'' Use Optional when the miss needs no reason -- a lookup that found
'' nothing -- and Result when it does.

dim o as Optional( of integer ) = Some( 42 )
print o.HasValue( )          '' true
print o.Value( )             '' 42

dim r as Result( of int32, ustring ) = Fail( of int32, ustring )( "not a number" )
print r.IsOk( )              '' false
print r.Failure( )           '' not a number -- the part Optional cannot carry

Library: Result
Category: Result
Documented under: Result Or Optional?

Clone this wiki locally