From: Jeremy Henty Date: 2006-07-16T06:15:05+09:00 Subject: Re: Devious or what? : hacking super : should this work? On 2006-07-15, dblack@wobblini.net wrote: > On Sun, 16 Jul 2006, Jeremy Henty wrote: > >> If you bind the entire argument list to a variable you can modify >> the list before calling "super". Check it out: > > ... super should be pretty transparent; for example, if an argument > is for some reason going to be altered in place by the original > method, you want that to still happen when you call the method that > calls super. True, but that's not what surprised me. Given "def foo(*args) ..." I always expected the *members* of args to be the arguments of the method call (and not copies of them). I did not expect args *itself* to be part of the Ruby call stack. I assumed it was just a temporary object created on the fly to give me access to the method arguments. I thought that nothing else in Ruby had a reference to it, so I expected that modifying args itself (rather than its members) would have no effect outside of the current scope. But I was wrong. It looks like args is the actual array of method arguments in the Ruby call stack. Modifying args changes the call stack, causing super to supply a different list of objects to the parent method. Regards, Jeremy Henty