ResTUnwrapOrAsync Method

(async version) 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.
C#
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.

Definition

Namespace: Orx.Fun.Result
Assembly: Orx.Fun.Result (in Orx.Fun.Result.dll) Version: 1.3.0+344c8bdd6f720ccfb2d8db7c61b76cf02be18f5f
C#
public Task<T> UnwrapOrAsync(
	Func<Task<T>> lazyFallbackValue
)

Parameters

lazyFallbackValue  FuncTaskT
Function to be called lazily to create the return value if the option is None.

Return Value

TaskT

See Also