1 # depends on: class.rb module.rb
23 "#<Tuple:0x#{object_id.to_s(16)} #{fields} elements>"
37 t = Tuple.new(size + o.size)
38 each_with_index { |e, i| t[i] = e }
39 o.each_with_index { |e, i| t[i + size] = e }
46 str << ": #{join(", ", :inspect)}"
52 def join(sep, meth=:to_s)
53 join_upto(sep, fields, meth)
56 def join_upto(sep, count, meth=:to_s)
58 return str if count == 0 or empty?
59 count = fields if count >= fields
63 str << at(i).__send__(meth)
67 str << at(count).__send__(meth)
72 return false unless Tuple === other and fields == other.fields
75 return false unless at(i) === other.at(i)
90 return self unless fields > 0
91 t = Tuple.new(fields-1)
92 t.copy_from self, 1, 0
96 # Swap elements of the two indexes.
106 t.copy_from self, 0, 0
113 alias_method :size, :fields
114 alias_method :length, :fields