On 01.11.2008 21:21, Jason Leong wrote:

>> Well, it seems you have to access paths to an event: lookup by date and
>> lookup by event id.  I do not know whether there are other access paths
>> (e.g. search for event name or such) but assuming for the moment that
>> there are just the two a solution with two Hashes seems most appropriate
> 
> That's correct! And by highlighting the access paths you've helped me 
> narrow it down to one of the challenges I've come across. I have the 
> event id which I could use to delete an event from the array indexed by 
> event hash - but this doesn't delete the event indexed by id hash (or 
> does it? I'll give it a go).

Please look carefully at the code.  Although untested it should do 
exactly this: delete from the other Hash.  Note that the return value of 
Hash#delete is the deleted element.  I probably should have added a 
safety check to ensure nil does not cause errors.  So you'd probably 
rather do

   def delete_by_id(id)
     dlt = @ev_by_id.delete(id) and dlt.each do |ev|
       @ev_by_date[ev.date].delete(ev)
     end
   end


Kind regards

	robert