From: Martin DeMello Date: 2009-02-16T21:20:47+09:00 Subject: Re: How to do this complicated logic in ruby On Mon, Feb 16, 2009 at 5:37 PM, Robert Klemme wrote: > EntryKey = Struct.new :server, :hosp, :loc do > def self.create(entry) > new(*members.map {|m| entry[m]}) > end > end > > index = Hash.new {|h,k| h[k] = []} > # loop reading input > entry = ... > index[EntryKey.create(entry)] << entry > > # now you can process them or do it while reading > > See also Martin's reply which goes into the same direction just with a > different approach. The different approach is mostly due to the fact that I'm uncomfortable using objects with mutable fieds as hash keys. I prefer to explicitly map them to a string, and then use that string as a hash key. martin