ResTBitwiseOr(ResT, FuncT, Res) Operator

Limited ahd experimental for now; waiting for generics in operator overloading to be actually useful.

Returns the error when IsErr; map(Unwrap()) when IsOk flattenning the result. Shorthand combining Map and Flatten calls.
C#
static Res<Team> TryGetTeam() { .. } // tries to grab a team; might fail, hence, returns Res.
static Res TryPutTeam(Team team) { .. } // tries to put the team; might fail, hence, returns Res.

Res result = TryGetTeam().FlatMap(TryPutTeam);
// equivalently:
Res result = TryGetTeam().FlatMap(team => TryPutTeam(team));

// this is a shorthand for:
Res result = TryGetTeam()   // Res<Team>
    .Map(TryPutTeam)        // 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 static Res operator |(
	Res<T> result,
	Func<T, Res> map
)

Parameters

result  ResT
Result to flat-map.
map  FuncT, Res
Function to flat-map the result if it is of Ok variant.

Return Value

Res

See Also