ResBitwiseOr Operator

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

Returns the error when IsErr; map() when IsOk, flattenning the result. This is a shorthand for sequential Map and Flatten calls.
C#
// assume we have two methods that can fail; hence returns a Res:
static Res TryRunRiskyOperation() { .. }
static Res TryLogCompletion() { .. }

// we want to call both operations; but the second one only if the first one succeeds.
Res result = TryRunRiskyOperation().FlatMap(TryLogCompletion);
// alternatively:
Res result = TryRunRiskyOperation().FlatMap(() => TryLogCompletion());

// this is equivalent to:
Res result = TryRunRiskyOperation().Map(() => TryLogCompletion()/*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 result,
	Func<Res> map
)

Parameters

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

Return Value

Res

See Also