Either<L, R> class
sealed
Represents a value that can be either a Left (error) or Right (success).
Either is commonly used in functional programming to handle computations that may fail without throwing exceptions.
- Implementers
- Available extensions
Properties
Methods
-
filter(
bool predicate(R), L orElse()) → Either< L, R> -
Available on Either<
Filters the right value with a predicate, converting to Left if falseL, R> , provided by the EitherExtensions extension -
flatMap<
R2> (Either< L, R2> f(R)) → Either<L, R2> - Flat maps the right value if this is a Right
-
flatMapLeft<
L2> (Either< L2, R> f(L)) → Either<L2, R> - Flat maps the left value if this is a Left
-
fold<
T> (T onLeft(L), T onRight(R)) → T - Folds this Either into a single value
-
getOrElse(
R defaultValue) → R - Returns the right value if this is a Right, otherwise returns the default value
-
getOrElseGet(
R defaultValue()) → R - Returns the right value if this is a Right, otherwise computes and returns a default value
-
map<
R2> (R2 f(R)) → Either< L, R2> - Maps the right value if this is a Right, otherwise returns this Left unchanged
-
mapLeft<
L2> (L2 f(L)) → Either< L2, R> - Maps the left value if this is a Left, otherwise returns this Right unchanged
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
swap(
) → Either< R, L> - Swaps Left and Right
-
toList(
) → List< R> -
Available on Either<
Converts this Either to a list, containing the right value or empty for LeftL, R> , provided by the EitherExtensions extension -
toNullable(
) → R? -
Available on Either<
Converts this Either to a nullable value, returning null for LeftL, R> , provided by the EitherExtensions extension -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited