Commits

Zachary Voase  committed 087147d

Added an == method to the Maybe monad.

  • Participants
  • Parent commits 554b816

Comments (0)

Files changed (1)

File lib/tweed/monads/maybe.rb

         "#{self.class.inspect}#{repr}"
       end
       
+      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
+      
       # An example of safe division implemented over the Maybe monad.
       module SafeDivision
         def /(other)