This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Either<TLeft, TRight> | |
{ | |
private readonly TLeft _left; | |
private readonly TRight _right; | |
private readonly bool _isLeft; | |
public Either(TLeft left) | |
{ | |
_left = left; | |
_isLeft = true; | |
} | |
public Either(TRight right) | |
{ | |
_right = right; | |
_isLeft = false; | |
} | |
public T Match<T>(Func<TLeft, T> left, Func<TRight, T> right) | |
{ | |
return _isLeft ? left(_left) : right(_right); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment