Sha256: e2f4462a63de6b7d6a66bea75cafed998aa0212f244a08d92d9acf60f7ba6bc6
Contents?: true
Size: 815 Bytes
Versions: 1
Compression:
Stored size: 815 Bytes
Contents
module Eithers private def left(value) Either.left(value) end def right(value) Either.right(value) end end class Either include Comparable def self.left(value) Left.new(value) end def self.right(value) Right.new(value) end end class Left < Either def initialize(value) @value = value end def is_left? true end def is_right? false end def left @value end def right raise NoSuchElementException.new end def <=>(other) @value <=> other.left end end class Right < Either def initialize(value) @value = value end def is_left? false end def is_right? true end def left raise NoSuchElementException.new end def right @value end def <=>(other) @value <=> other.right end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
totally_lazy-0.1.26 | lib/totally_lazy/either.rb |