From: James Coglan Date: 2009-01-26T04:39:21+09:00 Subject: Re: How can I get the arguments passed to the caller. --000e0cd58d90c0ff27046153cd34 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit > I have a rather weird question. I want to write a function that > programatically determines the arguments passed to its caller. Say, if i do > > $stuff = [] > > def bar(arg) > foo > end > > def foo > 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: def bar(*args) foo(binding) end => nil def foo(env) puts env.eval("args.first") end => nil bar 'something' something I don't think you can do this transparently. You can't even refer to the argument list within a single method (I'm thinking of the 'arguments' object in JavaScript) without mentioning the arguments by name. --000e0cd58d90c0ff27046153cd34--