Skip to content

Nullable<T>

Represents a value type that can be assigned Null

Definition

Unit: Neslib.Iceoryx2.System

type Nullable<T> = record ... end;

Type Parameters

T:

Properties

Name Description
HasValue A value indicating whether this nullable has a valid value of its underlying type.
Value The value, if it has been assigned a valid underlying value.

Constructors

Name Description
Create Creates a nullable with a given value.

Operators

Name Description
Equal Compares two nullables for equality.
Explicit Explicitly converts from a nullable to its underlying value.
Implicit(Pointer) Implicitly converts from nil to a nullable. This sets the HasValue of the nullable to False.
Implicit(T) Implicitly converts from a value to a nullable. This sets the HasValue of the nullable to True.
NotEqual Compares two nullables for inequality.

Methods

Name Description
CreateNull Creates a nullable with value null.
SetNull Sets the value to null.
ValueOr Returns the value if available, or otherwise the given default value.

Property Descriptions

HasValue

A value indicating whether this nullable has a valid value of its underlying type.

property HasValue: Boolean read FHasValue

Type: Boolean


Value

The value, if it has been assigned a valid underlying value.

property Value: T read GetValue

Type: T

Exceptions

EInvalidOperation: If HasValue is False.


Constructor Descriptions

Create

Creates a nullable with a given value.

constructor Create(const AValue: T)

Parameters

AValue: T : The value to set the nullable to.

Remarks

This will also set HasValue to True.


Operator Descriptions

Equal(Nullable, Nullable)

Compares two nullables for equality.

class operator Equal(const ALeft, ARight: Nullable<T>): Boolean

Parameters

ALeft: Nullable<T>

ARight: Nullable<T>

Returns

Boolean


Explicit(Nullable)

Explicitly converts from a nullable to its underlying value.

class operator Explicit(const AValue: Nullable<T>): T; inline; static

Parameters

AValue: Nullable<T>

Returns

T

Exceptions

EInvalidOperation: If HasValue is False.


Implicit(Pointer)

Implicitly converts from nil to a nullable. This sets the HasValue of the nullable to False.

class operator Implicit(const AValue: Pointer): Nullable<T>; inline; static

Parameters

AValue: Pointer

Returns

Nullable<T>


Implicit(T)

Implicitly converts from a value to a nullable. This sets the HasValue of the nullable to True.

class operator Implicit(const AValue: T): Nullable<T>; inline; static

Parameters

AValue: T

Returns

Nullable<T>


NotEqual(Nullable, Nullable)

Compares two nullables for inequality.

class operator NotEqual(const ALeft, ARight: Nullable<T>): Boolean

Parameters

ALeft: Nullable<T>

ARight: Nullable<T>

Returns

Boolean


Method Descriptions

CreateNull

Creates a nullable with value null.

class function CreateNull: Nullable<T>; inline; static

Returns

Nullable<T>


SetNull

Sets the value to null.

procedure SetNull; inline


ValueOr(T)

Returns the value if available, or otherwise the given default value.

function ValueOr(const ADefault: T): T; inline

Parameters

ADefault: T : The default value in case no value is available.

Returns

T