On Aug 18, 2007, at 12:59 AM, Matthew B Gardner wrote:

> Hello, I'm baffled by the following problem:
>
> I have an Account class and an external array that keeps them in a  
> list. I'm
> trying to delete the account objects one at a time as needed, by:
>
> class Account
> 	def quit
> 		array_name.delete self
> 	end
> end
>
> However, this is deleting every account in the list (array_name ==  
> []). I've
> verified that the account objects are unique. Just for an example,  
> this is
> the equivalent of what's happening:
>
> class Account
> 	def quit arr
> 		arr.delete self
> 	end
> end
>
> a1 = Account.new
> a2 = Account.new
> arr = []
> arr << a1
> arr << a2
> a1.quit arr
> arr #=> []
>
> Has anyone else experienced this problem, or know what the likely  
> cause is? I
> have other arrays that work in the exact same fashion and work as  
> expected.

I ran your code and I didn't have a problem: it did what you  
expected. Are you sure that the code you posted is exactly the same  
as the code that is giving you trouble?

Regards, Morton