Interface Either<L,R>

Type Parameters:
L - type of the left value, negative case
R - type of the right value, positive case
All Superinterfaces:
Applicable<Either<L,?>,R>, Bindable<Either<L,?>,R>, EitherOf<L,R>, Kind<Either<L,?>,R>, Mappable<Either<L,?>,R>
All Known Implementing Classes:
Either.Left, Either.Right

public sealed interface Either<L,R> extends EitherOf<L,R>, Bindable<Either<L,?>,R>, Applicable<Either<L,?>,R> permits Either.Left<L,R>, Either.Right<L,R>

This type represents two possible values, called left or right. In general left case is considered the negative case, and right case the positive case, so is right biased

  • Either.left(value): left value
  • Either.right(value): right value

Usually this type is used to represent a function return type. The left value represents when the function fails, and the right value when function returns normally. It's the functional alternative to exceptions.

Try<T> and Either<Throwable, T> are isomorphisms.