Class: Monads::Maybe
Class Method Summary collapse
-
.unit(value) ⇒ Object
- unit
-
a -> M a.
Instance Method Summary collapse
-
#bind(&block) ⇒ Object
- bind
-
(a -> M b) -> M a -> M b.
-
#unwrap(default_value) ⇒ Object
- unwrap
-
a -> M a -> a.
Methods included from Monad
#fmap, included, #initialize, #join, #method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Monads::Monad
Class Method Details
Instance Method Details
#bind(&block) ⇒ Object
- bind
-
(a -> M b) -> M a -> M b
11 12 13 |
# File 'lib/ruby-monads/maybe.rb', line 11 def bind(&block) ensure_monadic_result(&block).call end |
#unwrap(default_value) ⇒ Object
- unwrap
-
a -> M a -> a
16 17 18 |
# File 'lib/ruby-monads/maybe.rb', line 16 def unwrap(default_value) @value || default_value end |