ResTUnwrapOr(FuncT) Method
Returns the underlying value when
IsOk; or returns
lazyFallbackValue() when
IsErr.
This is a safe way to unwrap the result, by explicitly handling the Err variant.
Use the eager
UnwrapOr(T) variant if the fallback value is cheap or readily available.
static string ParseUserTablename(..) { /*parses the table name from command line input; might throw!*/ }
static string QueryUserTablename(..) { /*makes an expensive db-call to find out the table name*/ }
string userTable = Ok() // Res, certainly Ok
.TryMap(() => ParseUserTablename(..)) // Res<string>: might be Err if parser throws
.UnwrapOr(() => QueryUserTablename(..)); // directly returns ParseUserTablename's result if it is Ok;
// calls QueryUserTablename otherwise and returns its result.
Namespace: Orx.Fun.ResultAssembly: Orx.Fun.Result (in Orx.Fun.Result.dll) Version: 1.3.0+344c8bdd6f720ccfb2d8db7c61b76cf02be18f5f
public T UnwrapOr(
Func<T> lazyFallbackValue
)
- lazyFallbackValue FuncT
- Function to be called lazily to create the return value if the option is None.
T