Kit
Functions

wrapNullable

wrapNullable<T>(nullable): Option<T>

Wraps a nullable value into an Option.

  • If the input value is null, this function returns None.
  • Otherwise, it wraps the value in Some.

Type Parameters

Type ParameterDescription
TThe type of the contained value.

Parameters

ParameterTypeDescription
nullablenull | TThe nullable value to wrap.

Returns

Option<T>

An Option wrapping the value.

Example

Wrapping nullable values.

wrapNullable('Hello World'); // Option<string> (Some)
wrapNullable<string>(null);  // Option<string> (None)

See

On this page