Holds a single value of one of two types (L or R).
For efficiency, this is a struct, but this makes it possible to default-construct it. In that case its value will be default(R)
.
|
static Either< L, R > | R (value) |
|
static Either< L, R > | R (value) |
|
| Either (L value) |
|
| Either (R value) |
|
Either< L2, R2 > | Select< L2, R2 > (Func< L, L2 > selectL, Func< R, R2 > selectR) |
| Converts an Either to another with different types. More...
|
|
Either< L2, R2 > R2(selectL(_left)) Either< L2, R > | MapLeft< L2 > (Func< L, L2 > selectL) |
| Transforms Left with the given selector, if Left.HasValue . Otherwise, returns Right unchanged. More...
|
|
Either< L2, R2 > R2(selectL(_left)) Either< L2, R > R(selectL(_left)) Either< L, R2 > | MapRight< R2 > (Func< R, R2 > selectR) |
| Transforms Right with the given selector, if Right.HasValue . Otherwise, returns Left unchanged. More...
|
|
Either< L2, R2 > R2(selectL(_left)) Either< L2, R > R(selectL(_left)) Either< L, R2 > R2(selectR(_right)) Either< L, R > | IfLeft (Action< L > actionL) |
| Runs actionL if Left.HasValue . Equivalent to Left.Then(actionL) , but also returns this . More...
|
|
Either< L, R > | IfRight (Action< R > actionR) |
| Runs actionR if Right.HasValue . Equivalent to Right.Then(actionL) , but also returns this . More...
|
|
|
static Either< L, R > | NewLeft (L value) |
| Simply calls the constructor. This method exists to make it possible to construct an Either when both types are the same. More...
|
|
static Either< L, R > | NewRight (R value) |
| Simply calls the constructor. This method exists to make it possible to construct an Either when both types are the same. More...
|
|
static implicit | operator Either< L, R > (L value) |
|
static implicit | operator Either< L, R > (R value) |
|
static Either< L, R > | From< L2, R2 > (Either< L2, R2 > x) |
| Does an upcast, e.g. Either{string,ArgumentException} to Either{object,Exception}. C# does not allow defining conversion operators to take generic parameters, so you'll have to put up with this hassle instead. More...
|
|
Does an upcast, e.g. Either{string,ArgumentException} to Either{object,Exception}. C# does not allow defining conversion operators to take generic parameters, so you'll have to put up with this hassle instead.
Sadly, automatically upcasting value types to reference types doesn't seem possible.
- Type Constraints
-
L2 | : | L | |
R2 | : | R | |
R2 | : | new | |
R2 | : | Either | |
R2 | : | L | |
R2 | : | R | |
R2 | : | x._hasLeft | |
R2 | : | x._left | |
R2 | : | x._right | |