Final class FH\Option<+T>
Optional values. Use this instead of ?T
when you need Option<Option<T>>
, Option<?T>
, or Option<mixed>
.
Static methods
make(?T $x): Option<T>
- Return an option from a nullable value.
none(): Option<T>
- Return the empty option.
some(T $x): Option<T>
- Return an option with the given value. The nullness of the given value is not considered; this function always returns a non-empty option.
Instance methods
nullable(): ?T
- Turn an option into a nullable value.
option<TR>(TR $onNone, (function(T): TR) $onSome): TR
optionL<TR>((function(): TR) $onNone, (function(T): TR) $onSome): TR
map<TM>((function(T): TM) $f): Option<TM>
bind<TM>((function(T): Option<TM>) $f): Option<TM>