struct Monads::Nothing(T)
- Monads::Nothing(T)
- Monads::Maybe(T)
- Monads::Monad(T)
- Monads::Functor(T)
- Struct
- Value
- Object
Defined in:
monads/maybe.crConstructors
Instance Method Summary
-
#<=>(other : Nothing)
The comparison operator.
-
#<=>(other : Just)
The comparison operator.
-
#<=>(other : Maybe)
The comparison operator.
- #bind(lambda : _ -> Maybe(U)) forall U
- #fmap(lambda : _ -> U) forall U
- #map_or(default : U, lambda : _ -> _) forall U
- #or(default : Maybe)
- #or(lambda : -> _)
-
#to_s
Returns a nicely readable and concise string representation of this object, typically intended for users.
- #value_or(default : U) forall U
Instance methods inherited from struct Monads::Maybe(T)
<=>(other : Nothing)<=>(other : Just) <=>, inspect(io) inspect, just? just?, map_or(default : U, lambda : T -> U) forall U
map_or(default : U, &block : T -> U) forall U map_or, nothing? nothing?, or(default : Maybe)
or(lambda : -> _)
or(&block : -> U) forall U or, to_s to_s, value_or(default : U) forall U
value_or(&block : E -> U) forall U value_or
Constructor methods inherited from struct Monads::Maybe(T)
new
new
Class methods inherited from struct Monads::Maybe(T)
return(v : T)
return
Instance methods inherited from struct Monads::Monad(T)
>>(other : Monad(U)) forall U
>>,
|(other : _ -> Monad(U)) forall U
|,
bind(lambda : T -> Monad(U)) forall Ubind(&block : T -> Monad(U)) forall U bind
Constructor methods inherited from struct Monads::Monad(T)
new
new,
return(v : T) : self
return
Instance methods inherited from struct Monads::Functor(T)
fmap(lambda : T -> U)fmap(&block : T -> U) forall U fmap, initialize initialize
Constructor methods inherited from struct Monads::Functor(T)
new
new
Constructor Detail
Instance Method Detail
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]
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]
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]
Returns a nicely readable and concise string representation of this object, typically intended for users.
This method should usually not be overridden. It delegates to
#to_s(IO)
which can be overridden for custom implementations.
Also see #inspect
.