Sha256: c4f194ac5071aac922f3feab9077a4437fcf74f7cb07eaa330b17c4c73bf7338
Contents?: true
Size: 575 Bytes
Versions: 15
Compression:
Stored size: 575 Bytes
Contents
module Pair def pair(first, second) Pair.new(first, second) end class Pair include Comparable def initialize(first, second) @first = -> { first } @second = -> { second } end def first @first.() end def second @second.() end def enumerator Enumerator.new { |y| y << first y << second raise StopIteration.new } end def <=>(other) (first <=> other.first) <=> (second <=> other.second) end def to_s "(#{first}, #{second})" end end end
Version data entries
15 entries across 15 versions & 1 rubygems