Either<L, R>.iff constructor

Either<L, R>.iff(
  1. bool condition,
  2. Map0<L> leftProvider,
  3. Map0<R> rightProvider
)

Creates an left-sided Either from the leftProvider, if condition is true. Otherwise, create a right-sided Either from the rightProvider.

Implementation

factory Either.iff(
  bool condition,
  Map0<L> leftProvider,
  Map0<R> rightProvider,
) =>
    condition
        ? Either<L, R>.left(leftProvider())
        : Either<L, R>.right(rightProvider());