On Aug 13, 2006, at 7:19 PM, Hal Fulton wrote: > Trans wrote: >> Also, while not a full fledged class in it's own right, you might >> find >> Facets' association.rb useful. Ex. >> c = [ :a >> 1, :b >> 2 ] >> c.each { |k,v| puts "#{k} associated with #{v} } > > I've seen that, and it's kind of cool. > > But you can't use an object as a key if it already defines >> for > something else (e.g. Fixnum). > > > Hal > This is probably too verbose, even for a stop gap solution but: class AssocList def initialize(first, second) @array = [ [ first.keys.first, first.values.first ], [ second.keys.first, second.values.first ] ] end def <(other) @array << [ other.keys.first, other.values.first ] self end end class Hash def <(other) AssocList.new(self, other) end end {:a=>1} < {:b=>2} < {:c=>3} => #<AssocList:0x328564 @array=[[:a, 1], [:b, 2], [:c, 3]]> I was going for f(:a => 1 < :b => 2) but the operator precedence isn't right :(