Options
All
  • Public
  • Public/Protected
  • All
Menu

File Option

The Option type expresses that a value may be present or not. The code is organized through the class None (value not present), the class Some (value present), and the type alias Option (Some or None).

Finally, "static" functions on Option are arranged in the class OptionStatic and are accessed through the global constant Option.

Examples:

Option.of(5);
Option.none<number>();
Option.of(5).map(x => x*2);

To get the value out of an option, you can use Some.getOrThrow, or Some.get. The latter is available if you've checked that you indeed have a some, for example:

const opt = Option.of(5);
if (opt.isSome()) {
    opt.get();
}

You also have other options like Some.getOrElse, Some.getOrUndefined and so on. Some and None have the same methods, except that Some has the extra Some.get method that None doesn't have.

Index

Classes

Type aliases

Variables

Type aliases

Option

Option: Some<T> | None<T>

An Option is either Some or None "static methods" available through OptionStatic

param

the item type

Variables

Option

Option: OptionStatic = new OptionStatic()

The Option constant allows to call the option "static" methods

Generated using TypeDoc