From: Mike Jo Date: 2008-09-22T05:24:44+09:00 Subject: Re: Instance variable acting like class variable? Thomas B. wrote: > 3. My guess for your main problem is that you create just one instance > of Node and then assign it to all the places where you want to keep your > nodes. If you create your nodes like this: > nodes=Array::new(num_nodes,Node::new(args)) then this is the case - you > create one node and populate the array with pointers to the node. (The > correct solution would be nodes=Array::new(num_nodes){Node::new(args)} > because this form calls the block for each newly created elements, so > you'd have num_nodes separate nodes.) But it's just my guess, you'd have > to post your code that creates the nodes to verify it. > > TPR. I do have an array of Node objects, but I'm calling Node.new(args) each times I add a node to the array. Example: @nodes = Array.new @nodes << Node.new(args) -- Posted via http://www.ruby-forum.com/.