Other Enumerations
The following enumerations are available globally.
-
An unbiased tagged union or sum type of exactly two possible cases,
.aand.b, having typesAandBrespectively.When NOT to use Either: if there are asymmetrical semantics (e.g.
Ais special in some manner), or when there are better names (i.e. meaning) that can be attached to the cases, a domain-specificenumoften results in more maintainable code and easier to use APIs.When to use Either: good applications of
See moreEithercome up in generic programming where there are no defined semantics or information that can be gained from naming or biasing one of the two cases.Declaration
Swift
public enum Either<A, B>extension Either: CustomStringConvertibleextension Either: Equatable where A: Equatable, B: Equatableextension Either: Comparable where A: Comparable, B: Comparableextension Either: Hashable where A: Hashable, B: Hashable
View on GitHub
Other Enumerations Reference