From: Mark Wilson Date: 2003-08-05T06:03:10+09:00 Subject: Re: clearing a parameter in Ruby? On Monday, August 4, 2003, at 03:56 PM, Roy Patrick Tan wrote: > [snip] > In essence, what I'm trying to do is create a set of container classes > that, when an object is inserted into a container, the container > guarantees that the object does not change state until it is taken out > again. This sounds a little like a tuple. See http://sourceforge.net/project/showfiles.php?group_id=50485 which includes an implementation of a tuple class (a container that is ordered and immutable). The code, which is not very long, is at the bottom of this page: http://www.rubygarden.org/ruby?AdditionalSetMethods > The problem is that in Ruby (and almost all modern imperative > languages) two variables can refer to the same object. So part of the > solution is never to use assignment except when creating an object (if > you need a copy of an object, clone it). But that still leaves us w > parameter passing, since a variable in the caller environment refers > to an object that is also referred to by a variable in the called > method... so I wanted to be able to clear the caller's variable. I don't understand the problem here. Why are the variables important as long as you are passing the object around? Every value in Ruby is also an object -- even if it's assigned to a variable within a class, an instance of a class or a method. I still don't understand what you want your program to do. > [snip]