Either

A interface to represent a two possible value.

Members

Functions

left
TLeft left()

Return TLeft value if this is the Left!(TLeft, TRight) instance, otherwise throw Exception.

right
TRight right()

Return TRight value if this is the Right!(TLeft, TRight) instance, otherwise throw Exception.

tryLeft
Maybe!TLeft tryLeft()

Return Just!TLeft value if this is the Left!(TLeft, TRight) instance, otherwise Nothing!TLeft value.

tryRight
Maybe!TRight tryRight()

Return Just!TRight value if this is the Right!(TLeft, TRight) instance, otherwise Nothing!TRight value.

Properties

isLeft
bool isLeft [@property getter]

Return true if this is the Left!(TLeft, TRight) instance, otherwise false.

isRight
bool isRight [@property getter]

Return true if this is the Right!(TLeft, TRight) instance, otherwise false.

Static functions

left
Either!(TLeft, TRight) left(TLeft value)

A factory method to create Left(TLeft, TRight) instance.

right
Either!(TLeft, TRight) right(TRight value)

A factory method to create Right(TLeft, TRight) instance.

Examples

1 auto either = Either!(string, int).right(33-4);
2 if (either.isRight)
3 {
4    writeln(either.right());
5 }

Output:

29

Meta