Rick Denatale wrote:


> Every instance of Node will have it's own instance variable, BUT
> 
> assume that you do
> 
>     n1 = Node.new(r1, c1, cost1, direction1)
>     n2 = Node.new(r2, c2, cost2, direction2, n1)
> 
> Now since Array#to_a returns self (i.e. the same array), n2.collected 
> will
> refer to exactly the same array as n1.collected, and so any changes to 
> the
> object will be visible through either instance variable.
> 
> If you change the parent.collected.to_a to parent_collected.dup then it 
> will
> break this alias by making a shallow copy of the parents array at the 
> time
> of initialization, but, not knowing what you are trying to do, this 
> might or
> might not fix your actual problem.
>  
> --
> Rick DeNatale

Rick,
That was exactly what I needed. Thank you!
-- 
Posted via http://www.ruby-forum.com/.