From: Florian Gross Date: 2004-10-21T04:39:17+09:00 Subject: Re: hash << Matt Maycock wrote: > So, unless you count merge! and update, there doesn't seem to be a way > to shove stuff into a hash and get the resulting updated hash back. I'm not sure, but maybe KeyedList could help here. It is a Hash that has list-style insert operations: > Struct.new("Hero", :name, :reason) > > # Create a KeyedList which will be keyed by the names > # of its heroic elements. > list = KeyedList.new { |hero| hero.name } > # Adds elements to the KeyedList. > list << Struct::Hero.new("Yukihiro Matsumoto", "Ruby") > list << Struct::Hero.new("Larry Wall", "Enhanced regular expressions") > list << Struct::Hero.new("Randal Schwartz", "Schwartzian transform") > > list.size # => 3 > list["Yukihiro Matsumoto"].reason # => "Ruby" It is both available as a Gem and from RPA. Regards, Florian Gross