From: salamond Date: 2010-10-21T23:42:16+09:00 Subject: Re: about handling args in block Let's see if I get this. While I'm passing @left_node, and @right_node into this block, I'm passing the reference of these 2 objects into a block. Inside block, I can use these 2 references to modify the objects, but I can't change the reference themselves. Now here comes an update, is there a way to have the class destroy itself? like class Node #snip def destroy self = nil end end [@left_node, @right_node].each do |node| node.destroy end Is it possible to have something like this work? When I try this, it said can't change the value of self. On Thu, Oct 21, 2010 at 7:09 PM, Robert Klemme wrote: > Please do not top post. > > On Thu, Oct 21, 2010 at 12:38 PM, salamond wrote: > >> I wanner do this because this tree may not be a binary tree. >> What if a node could link to a dozen nodes. > > In that case you would have a single collection (e.g. an Array) which > stores child nodes!  For that use Jesus's solution. > >> we have to something like this. >> nodes.each do |node| >>  node = nil >> end > > This won't work because you only assign to the block parameter and > leave "nodes" unchanged. > > Cheers > > robert > > -- > remember.guy do |as, often| as.you_can - without end > http://blog.rubybestpractices.com/ > >