From: Richard Lionheart Date: 2004-04-29T05:19:06+09:00 Subject: Re: Last minute details Hi Mark, Thanks. You must be a mind-reader :-) That's exactly the kind of thing I wanted to do. I tried to "undefine" the to_s modification by adding the following after the invocation of the modified Array: class Array def to_s self.to_s end end Of course, that netted me "stack level too deep (SystemStackError)" Again, I much appreciate your advice. It was especially generous of you to post your complete solution because I might not have known how to apply your suggestion. (In this case, happily, I understood your suggestion immediately.) Regards, Richard "Mark Sparshatt" wrote in message news:408FFEBE.8060008@yahoo.co.uk... > Richard Lionheart wrote: > > if you want to save the old version of to_s you can use the alias method > > class Array # Override to_s > alias old_to_s to_s > def to_s > join("; ") > end > end > > then you can access the old to_s behaviour by using the old_to_s method. > Or if you want to change to_s back to it's default behaviour you can use > > class Array > alias to_s old_to_s > end > > i.e. > > a = %w( foo bar ack) > puts "After assignment \"a = %w( foo bar ack)\", a.class.to_s = > #{a.class.to_s}" > b = %w(eeny meeny miney mo) > puts "Before override: a = #{a.to_s}, b = #{b.to_s}" > > class Array # Override to_s > alias old_to_s to_s > def to_s > join("; ") > end > end > > puts "After override: a = #{a.to_s}, b = #{b.to_s}" > > class Array > alias to_s old_to_s > end > > puts "After re-override: a = #{a.to_s}, b = #{b.to_s}" > > results=< After assignment "a = %w( foo bar ack)", a.class.to_s = > Array > Before override: a = foobarack, b = eenymeenymineymo > After override: a = foo; bar; ack, b = eeny; meeny; miney; mo > After re-override: a = foobarack, b = eenymeenymineymo > RESULTS > > -- > Mark Sparshatt > > > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.665 / Virus Database: 428 - Release Date: 4/26/2004