Table of Contents

Method Swap

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

Swap()

Exchanges the two cases. The first case becomes the second, and the second becomes the first.

[Pure]
public Either<T2, T1> Swap()

Returns

Either<T2, T1>

An either of the two types in the opposite order, holding the same value in the other position.

Remarks

Use this to give an either to code that names the same two types in the opposite sequence. Use it also to get to the first case with an operation that only addresses the second, or the opposite. Two exchanges give the initial value again. This exists only here, on the two-case either. With three or more cases there is no one change to make. A change is then a selection of one of some reorderings. The name Swap on one of them makes the others look unavailable, and not unnamed.