Skip to content

Modern Result IsOk

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

Home › Result › Result › IsOk

IsOk

Returns true if the Result holds a value rather than a reason for failure.

Syntax

IsOk( ) as boolean

Examples

#import "std/outcome"
using outcome

dim r as Result( of int32, ustring ) = Ok( of int32, ustring )( 42 )

'' The guard, and it costs nothing. READING THE WRONG SIDE RAISES:
'' Value( ) on a failure and Failure( ) on a success both raise
'' 'illegal function call', symmetrically.
if r.IsOk( ) then
    print r.Value( )         '' 42
else
    print r.Failure( )
end if

dim bad as Result( of int32, ustring ) = Fail( of int32, ustring )( "nope" )
print bad.IsOk( )            '' false

Library: Result
Category: Result
Documented under: Members

Clone this wiki locally