How to create blocks with arity known at runtime

Hi everyone,

is it possible to create blocks of arity known at runtime, other than
simply using a variable list of params: Proc.new { |*a| ... }

I'm looking for somthing like:
params = [:a, :b]
Proc.new { |*params| ... }

which is not legal Ruby obviously

Thanks.

I respond to myself, eval could be an option

···

On 2 abr, 12:03, abc <arcadiorubiogar...@gmail.com> wrote:

Hi everyone,

is it possible to create blocks of arity known at runtime, other than
simply using a variable list of params: Proc.new { |*a| ... }

I'm looking for somthing like:
params = [:a, :b]
Proc.new { |*params| ... }

which is not legal Ruby obviously

Thanks.

abc <arcadiorubiogarcia@gmail.com> writes:

Hi everyone,

is it possible to create blocks of arity known at runtime, other than
simply using a variable list of params: Proc.new { |*a| ... }

I'm looking for somthing like:
params = [:a, :b]
Proc.new { |*params| ... }

which is not legal Ruby obviously

You can, using eval.
Have a look at: http://groups.google.com/group/comp.lang.ruby/msg/56fce4adeaa79f68?hl=en

···

--
__Pascal Bourguignon__