Returns true
if the object has no value, otherwise returns false
.
Returns true
if the object has a value, otherwise returns false
.
Executes the func
with the value if the object has a value,
and returns the return value of the func
.
If the object has no value, just returns the value which is null or undefined.
Executes the func
with the value if the object has no value,
otherwise do nothing.
Executes the func
with the value if the object has a value,
otherwise do nothing.
Executes the func
with the value if the object has a value,
otherwise executes elseFunc.
Executes the func
with the value if the object has a value,
and returns new Optional object with the return value of the func
.
If the object has no value, just returns new Optional object without applying the func
.
Generated using TypeDoc
An object that represents nullable(undefinable) value.
const opt1 = new Optional<string>(hello); const opt2 = new Optional();