From: Roger Pack Date: 2008-07-10T08:45:00+09:00 Subject: Re: Faking named parameters and enforcing required params > So it appears that currently the only way to arbitrarily add a local > variable would be to hack the parse tree itself. Appears that ParseTree and ruby2ruby provide this type of functionality [see http://weblog.raganwald.com/2008/06/not-going-dark.html for an example]. So my question is say I've got a method def method1(a, b=3) ... end that I want to allow to accept named parameter [a la method1(2, :b => 3) or method1(:a => 2] I could either rewrite the original method's parse tree to allow for named parameters [i.e. convert it to] def method1(*args) a, b = args.parse [:a], {:b => 3} ... end then 'eval' the newly created function, replacing the original with the new or I could just write a caller function, a la alias :original_method1 :method1 def method1(*args) a, b = args.parse [:a], {:b => 3} original_method1(a, b) end so alias chain kind of. Any thoughts on which of these would might be preferable? Thanks! -R -- Posted via http://www.ruby-forum.com/.