OptTMatchTOut(FuncT, TOut, FuncTOut) Method

Maps into whenSome(Unwrap()) whenever IsSome; and into lazy whenNone() otherwise. Similar to MatchTOut(FuncT, TOut, TOut) except that None variant is evaluated only when IsNone.
C#
// assuming QueryAnonymousGreeting() is expensive.
Opt<User> user = GetOptionalUser(..);
string greeting = user.Match(u => $"Welcome back {u.Name}", () => QueryAnonymousGreeting());

Definition

Namespace: Orx.Fun.Option
Assembly: Orx.Fun.Option (in Orx.Fun.Option.dll) Version: 1.2.1+ea79806fa5e0e04bfdaef2a1916930e75e2cde74
C#
public TOut Match<TOut>(
	Func<T, TOut> whenSome,
	Func<TOut> whenNone
)

Parameters

whenSome  FuncT, TOut
Mapping function (T -> TOut) that will be called with Unwrapped value to get the return value when Some.
whenNone  FuncTOut
Function to be called lazily to get the return value when None.

Type Parameters

TOut

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

Return Value

TOut

See Also