From: Brian Candler Date: 2009-01-26T17:35:45+09:00 Subject: Re: How can I get the arguments passed to the caller. James Coglan wrote: >> first_arg = .... >> $stuff << first_arg >> end >> >> bar(42) >> >> # By this point, $stuff would be [42] > > > > I think the closest you're going to get is for the calling function to > pass > its binding so that foo can read from it: In which case, it might as well just pass its args instead :-) There is the Binding.of_caller hack which you can find through a google search. Maybe you could combine this with Kernel#local_variables or Binding#local_variables to do what you want? That's what debug.rb does when /^\s*l(?:ocal)?\s*$/ var_list(eval("local_variables", binding), binding) and just use eval to read them: def var_list(ary, binding) ary.sort! for v in ary stdout.printf " %s => %s\n", v, eval(v, binding).inspect end end -- Posted via http://www.ruby-forum.com/.