ResTFlatMapTOut(FuncT, ResTOut) Method

Returns None when IsNone; map(val) when IsOk flattening the result. Shorthand combining Map and Flatten calls.
C#
static Res<User> TryGetUser() {
    // method that tries to get the user, return Ok(user) or Err.
}
static Res< double> TryGetBalance(User user) {
    // method that tries to get usedr's balance; which might fail, returns:
    // Ok(balance) or Err
}
Res<double> balance = TryGetUser().FlatMap(TryGetBalance);
// equivalent to both below:
var balance = TryGetUser().FlatMap(user => TryGetBalance(user));
var balance = TryGetUser()              // Res<User>
    .Map(user => TryGetBalance(user))   // Res<Res>
    .Flatten();                         // Res

Definition

Namespace: Orx.Fun.Result
Assembly: Orx.Fun.Result (in Orx.Fun.Result.dll) Version: 1.3.0+344c8bdd6f720ccfb2d8db7c61b76cf02be18f5f
C#
public Res<TOut> FlatMap<TOut>(
	Func<T, Res<TOut>> map
)

Parameters

map  FuncT, ResTOut
Function (T -> Res<TOut>) mapping the underlying value to result of TOut if this.IsOk.

Type Parameters

TOut

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

Return Value

ResTOut

See Also