From: Geoff Youngs Date: 2003-08-05T03:47:33+09:00 Subject: Re: clearing a parameter in Ruby? On Tue, Aug 05, 2003 at 02:36:32AM +0900, Roy Patrick Tan wrote: > Hi, > is it possible to write a method that can "clear" a parameter in Ruby? > That is can a write a method "push" such that for the code below: > x = "Hello" > string_stack.push(x) > puts x > the output will be nil instead of "Hello"? As has already been mentioned the short answer is no. The alternative answer is that the desired effect might be acheived using SimpleDelegator. e.g. require 'delegate' def push(x) x.__setobj__(nil) end x = SimpleDelegator.new("Hello") puts x push(x) puts x TTFN, Geoff.