From: Robert Klemme Date: 2007-08-18T18:09:57+09:00 Subject: Re: Problem with Array#delete On 18.08.2007 08:34, Matthew B Gardner wrote: > Sorry, I only meant the code I posted as an example of what is happening -- > the actual code would be a little hard to gather and format, but I will do so > if the following isn't enough information: > > ruby -v #=> ruby 1.8.4 (2005-12-24) [i486-linux] > > Ok, I threw this code in to gather some info, and following it is the > printout: > > p world.characters.class > p world.characters.size > world.characters.each do |ch| > p ch.class > p ch.object_id > end > world.characters.delete(self) > p world.characters > > Array > 2 > Character > -607336504 > Character > -607410834 > [] > > Do I need to format up the code, or is there something telling from the > information here? The crucial bit is missing: how did you define ==, eql? and hash in your class? Did you define them? If not, using Struct might help because that gives you those methods for free: YourClass = Struct.new :name, :other_field do def method_you_need end end Then eql?, == and hash will be implemented in terms of "name" and "other_field". Kind regards robert