Method OrElse
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
OrElse<T>(Maybe<T>, Maybe<T>)
Returns this value if it has one, and the given value otherwise.
[Pure]
public static Maybe<T> OrElse<T>(this Maybe<T> a, Maybe<T> b)
Parameters
Returns
- Maybe<T>
aif it contains a value, andbotherwise.
Type Parameters
TThe type of the value.
Remarks
In a chain, this is a list of fallbacks. The first source with an answer wins, and the result has no value only when no source had one.
OrElse<T>(Maybe<T>, Func<Maybe<T>>)
Returns this value if it has one, and the result of the given function otherwise.
[Pure]
public static Maybe<T> OrElse<T>(this Maybe<T> a, Func<Maybe<T>> b)
Parameters
Returns
- Maybe<T>
aif it contains a value, and the result ofbotherwise.
Type Parameters
TThe type of the value.
Remarks
b runs only when a has no value.
Thus, use this version when a read of the fallback costs something, such as
a second lookup or a second parse.