Class: Tweed::Monads::Maybe
- Inherits:
-
Tweed::Monad
- Object
- Tweed::Monad
- Tweed::Monads::Maybe
- Defined in:
- lib/tweed/monads/maybe.rb
Overview
The Maybe monad
Defined Under Namespace
Modules: SafeDivision
Instance Method Summary collapse
Methods inherited from Tweed::Monad
Instance Method Details
#==(other) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/tweed/monads/maybe.rb', line 17 def ==(other) if other.is_a? Maybe [@value, @success] == other.instance_eval { [@value, @success] } else self.object_id == other.object_id || @value == other end end |
#inspect ⇒ Object
12 13 14 15 |
# File 'lib/tweed/monads/maybe.rb', line 12 def inspect repr = @success ? "[#{@value.inspect}]" : ".zero" "#{self.class.inspect}#{repr}" end |