Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Either ¶
type Either[A, B any] interface{}
Represents a value of one of two possible types (a disjoint union). An instance of Either is an instance of either Left or Right. A common use of Either is as an alternative to Option for dealing with possibly missing values. In this usage, None is replaced with a Left which can contain useful information. Right takes the place of Some. Convention dictates that Left is used for failure and Right is used for success. So left is often an error type but it does not have to be.
For example, you could use Either[String, Int] to indicate whether a received input is a String or an Int. Either is right-biased, which means that Right is assumed to be the default case to operate on. If it is Left, operations like Map and FlatMap return the Left value unchanged: