Skip to content

Result

Extends: RefCounted

Description

A virtual class that represents an arbitrary result from executing an operation. This class should never be used directly, it's only meant to be inherited from. The Result. All classes that expose operations which may fail, will also expose a "Status" enum that can be used to distinguish the different failure modes.

A virtual class that represents an arbitrary result from executing an operation. This class should never be used directly, it's only meant to be inherited from. The Result. All classes that expose operations which may fail, will also expose a "Status" enum that can be used to distinguish the different failure modes.

Method Descriptions

_init

func _init(res: _Result) -> Result

is_ok

func is_ok() -> bool

Returns true if the operation succeeded

is_err

func is_err() -> bool

Returns true if the operation failed

tag

func tag() -> int

Returns a tag representing the status of the operation. This can be used in pattern matching. Consult the [Status] enum of the class.

sequence (static)

func sequence(results: Array[Result]) -> ArrayResult

Convert an [Array] of [Result]s into a [Result] containing either an [Array] with [b]all[/b] of the values or the first error found in the [Array].

Sub-classes

Ok

Property Descriptions

value

var value: Variant
  • Getter: @value_getter

Method Descriptions

_init

func _init(value: Variant) -> Ok

Err

Property Descriptions

error

var error: String
  • Getter: @error_getter

Method Descriptions

_init

func _init(err: String, tag: int) -> Err

VariantResult

Property Descriptions

value

var value: Variant
  • Getter: @value_getter

WARNING: This function may fail! First match on Result.tag or call Result.is_ok.

error

var error: String
  • Getter: @error_getter

WARNING: This function may fail! First match on Result.tag or call Result._is_err.

ArrayResult

Property Descriptions

value

var value: Array
  • Getter: @value_getter

WARNING: This function may fail! First match on Result.tag or call Result.is_ok.

error

var error: String
  • Getter: @error_getter

WARNING: This function may fail! First match on Result.tag or call Result._is_err.