From: "ara.t.howard" Date: 2008-07-04T05:11:43+09:00 Subject: Re: Parameter name reflection On Jul 3, 2008, at 1:43 PM, Oliver Saunders wrote: > If I declare > > def foo(a, b) > end > > What code should I use to find the names of the parameters? > I only see these methods available on a Method object. > ["[]", "arity", "call", "to_proc", "unbind"] > > For instance in PHP I could do this > > function foo($a, $b) { } > $ref = new ReflectionFunction('foo') > $ref->getParameters()[0]->getName(); // a > $ref->getParameters()[1]->getName(); // b > -- > Posted via http://www.ruby-forum.com/. > cfp:~ > cat a.rb def foo a, b p local_variables end foo 4, 2 cfp:~ > ruby a.rb ["a", "b"] as to why you'd want to do this though - i've no idea. why not use options? def foo options = {} end foo :a => 4, :b => 2 ?? a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama