Swap

Troca o tipo do Either<TLeft, TRight> alterando os valores Right e Left.

Como usar

Este método deve ser utilizado quando for necessário alterar a ordem entre os valores TLeft e TRight.

Quando o valor Either está no estado IsRight

Either<string, int> either = 42;
Either<int, string> eitherResult = either.Swap();

//eitherResult.IsLeft = true
//eitherResult.Left = 42

Quando o valor Either está no estado IsLeft

Either<string, int> either = "Hello";
Either<int, string> eitherResult = either.Swap();

//eitherResult.IsRight = true
//eitherResult.Right = "Hello"

Last updated