Skip to content

TOptional

Ivan Semenkov edited this page Jan 27, 2021 · 2 revisions

Table of contents

About

TOptional class type can contains some value or none, like in Rust language.

uses
  utils.optional;
  
type
  generic TOptional<T> = class

Create

A new optional value can be created by call its constructor.

Use the following constructor to create a new TOptional of type None.

constructor Create;

Use the following constructor to create a new TOptional with a value.

 constructor Create (AValue : T);

IsSome

Checking if optional contains value.

function IsSome : Boolean;

Unwrap

Return stored value or raise TNoneValueException exeption if none.

function Unwrap : T;

TNoneValueException

Raised when trying to get a value that does not exist.

uses
  utils.optional;

type
  TNoneValueException = class(Exception)
Clone this wiki locally