struct

Monads::Right(E, T)

Inherits Monads::Either / Comparable / Monads::Monad / Monads::Functor / Struct / Value / Object

Constructors

new(data : T)
Source

Instance methods

<=>(other : Right)

The comparison operator. Returns 0 if the two objects are equal, a negative number if this object is considered less than other, a positive number if this object is considered greater than other, or nil if the two objects are not comparable.

Subclasses define this method to provide class-specific ordering.

The comparison operator is usually used to sort values:

# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]

# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]
Source
<=>(other : Either)

The comparison operator. Returns 0 if the two objects are equal, a negative number if this object is considered less than other, a positive number if this object is considered greater than other, or nil if the two objects are not comparable.

Subclasses define this method to provide class-specific ordering.

The comparison operator is usually used to sort values:

# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]

# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]
Source
<=>(other : Leftable)

The comparison operator. Returns 0 if the two objects are equal, a negative number if this object is considered less than other, a positive number if this object is considered greater than other, or nil if the two objects are not comparable.

Subclasses define this method to provide class-specific ordering.

The comparison operator is usually used to sort values:

# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]

# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]
Source
bind(lambda : T -> Either(E, U)) forall U
Source
fmap(lambda : T -> U) : Right(E, U) forall U
Source
fold(right_fn : T -> U, left_fn : E -> U) forall U

Fold/match the Either: applies right_fn if Right, left_fn if Left Returns the result of whichever function was applied

Example: result.fold( ->(account : Account) { json_response(account) }, ->(error : AuthError) { error_response(error) } )

Source
map_or(default : U, lambda : T -> U) forall U
Source
map_or(default : U, &block : T -> U) forall U
Source
or(other : Either)
Source
or(other : _ -> _) : Right(E, T)
Source
value!
Source
value_or(other : E -> _)
Source
value_or(other : _)
Source