Skip to content

Modern Optional HasValue

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

Home › Optional › Optional › HasValue

HasValue

Returns true if the Optional holds a value.

Syntax

HasValue( ) as boolean

Examples

#import "std/outcome"
using outcome

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

o.Clear( )
print o.HasValue( )          '' false

'' The guard before Value( ), which RAISES on an empty Optional.
'' This replaces the sentinel idiom, where -1 might be "absent" or might
'' be a legitimate index and nothing in the type says which.

Library: Optional
Category: Optional
Documented under: Members

Clone this wiki locally