Sha256: 4c92d790b476b7259e125c7bd026651c583516c585add7bd3359f4e92cf01b99
Contents?: true
Size: 429 Bytes
Versions: 1
Compression:
Stored size: 429 Bytes
Contents
require_relative 'tuple' class Pair < Tuple def initialize(*values) values.flatten.tap do |arguments| raise ArgumentError, 'Pair must contain only two elements' if more_than_two_arguments?(arguments) super(arguments[0], arguments[1]) end end alias_method :second, :last private def more_than_two_arguments?(arguments) arguments.length > 2 end end def Pair(*values) Pair.new(*values) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tuples-0.1.0 | lib/tuples/pair.rb |