ResTMatchTOut Method

Maps into whenOk(Unwrap()) whenever IsOk; and into whenErr(error-message) otherwise.
C#
Res<User> user = TryGetUser(..);
string greeting = user.Match(u => $"Welcome back {u.Name}", err => $"Failed to get user. {err}");
// equivalently:
greeting = user.Match(
    whenOk: u => $"Welcome back {u.Name}",
    whenErr: err => $"Failed to get user. {err}"
);

Definition

Namespace: Orx.Fun.Result
Assembly: Orx.Fun.Result (in Orx.Fun.Result.dll) Version: 1.3.0+344c8bdd6f720ccfb2d8db7c61b76cf02be18f5f
C#
public TOut Match<TOut>(
	Func<T, TOut> whenOk,
	Func<string, TOut> whenErr
)

Parameters

whenOk  FuncT, TOut
Mapping function (T -> TOut) that will be called with Unwrapped value to get the return value when Ok.
whenErr  FuncString, TOut
Function of the error message to get the return value when Err.

Type Parameters

TOut

[Missing <typeparam name="TOut"/> documentation for "M:Orx.Fun.Result.Res`1.Match``1(System.Func{`0,``0},System.Func{System.String,``0})"]

Return Value

TOut

See Also