From 634585d32773c1c0c40d5169ec432d27b3b01f3f Mon Sep 17 00:00:00 2001 From: moba1 Date: Wed, 24 Apr 2019 18:50:22 +0900 Subject: [PATCH] integrate `#inspect` in `Just` and `Nothing` into `Maybe` --- src/monads/maybe.cr | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/monads/maybe.cr b/src/monads/maybe.cr index d37d2f1..e50a380 100644 --- a/src/monads/maybe.cr +++ b/src/monads/maybe.cr @@ -17,6 +17,10 @@ module Monads Just.new(v) end + def inspect(io) + io << to_s + end + abstract def <=>(other : Maybe(T)) abstract def to_s abstract def inspect(io) @@ -44,10 +48,6 @@ module Monads "#{typeof(self)}{#{value!.inspect}}" end - def inspect(io) - io << to_s - end - def <=>(other : Maybe(T)) case other when Just(T) @@ -87,10 +87,6 @@ module Monads "#{typeof(self)}" end - def inspect(io) - io << to_s - end - def <=>(other : Maybe(T)) typeof(self) == typeof(other) ? 0 : nil end