From: salamond Date: 2012-11-13T11:16:44+09:00 Subject: Re: how to define method with variables in arg list --f46d0444eb9f4cf39204ce5702b0 Content-Type: text/plain; charset=ISO-8859-1 thanks, Brian. That's a great solution. It works. On Mon, Nov 12, 2012 at 11:23 PM, Brian Candler wrote: > salamond wrote in post #1084048: > > define_method(method_name) |*args| # problem is here. how can I > > define a method, with dynamic numbers of variables? > > I think class_eval %Q{def method(#{args.join(",")}) ... end} is your > best bet. > > -- > Posted via http://www.ruby-forum.com/. > > --f46d0444eb9f4cf39204ce5702b0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable thanks, Brian.

That's a great solution.
It= works.=A0



On Mon, Nov 12, 2012 at 11:23 PM, Brian Ca= ndler <lists@ruby-forum.com> wrote:
salamond wrote in post #1084048:
> =A0 =A0 =A0 define_method(method_name) |*args| # pro= blem is here. how can I
> define a method, with dynamic numbers of variables?

I think class_eval %Q{def method(#{args.join(",")}) ... end= } is your
best bet.

--
Posted via http://= www.ruby-forum.com/.


--f46d0444eb9f4cf39204ce5702b0--