Right<L, R> class

A concrete implementation of Either that represents the successful value (Right) in a computation.

Commonly used in functional programming to wrap a successful result, while the Left represents a failure or error.

Example usage:

Either<String, int> result = Right(42);
print(result.isRight()); // true
Inheritance

Constructors

Right(R value)
Creates a Right instance with the given value.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → R
The successful value held by this Right.
final

Methods

flatMap<R2>(Either<L, R2> f(R right)) Either<L, R2>
Applies the given function f to the contained value, and flattens the result.
override
fold<B>(B ifLeft(L left), B ifRight(R right)) → B
Applies ifRight to the contained value and returns its result.
override
getLeft() → L
Throws an Exception because this is a Right and does not contain a Left value.
override
getRight() → R
Returns the contained value.
override
isLeft() bool
Always returns false because this is a Right.
override
isRight() bool
Always returns true because this is a Right.
override
map<R2>(R2 f(R right)) Either<L, R2>
Transforms the contained value using the provided function f, returning a new Right.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited