OptTFlatMapTOut(FuncT, OptTOut) Method

Returns None when IsNone; map(val) when IsSome flattening the result. Shorthand combining Map and Flatten calls.
C#
static Opt<User> GetOptionalUser() {
    // method that tries to get the user, which can be omitted.
    ...
}
static Opt<string> GetNickname(User user) {
    // method that tries to get the nickname of the passed-in user; which is optional
    ...
}
Opt<string> nickname = GetOptionalUser().FlatMap(GetNickname);
// equivalent to both below:
nickname = GetOptionalUser().FlatMap(user => GetNickname(user));
nickname = GetOptionalUser().Map(user => GetNickname(user) /*Opt<Opt<string>>*/).Flatten();

Definition

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

Parameters

map  FuncT, OptTOut
Function (T -> Opt<TOut>) mapping the underlying value to option of TOut if IsSome.

Type Parameters

TOut

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

Return Value

OptTOut

See Also