Forum: Ruby on Rails instance_eval and Proc objects

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dan W. (Guest)
on 2006-02-10 17:47
(Received via mailing list)
Hi All,

Got a bit of a Ruby question for you.

If I have a function that makes a proc object like this:

def select(selector, &proc)
  el =
  el.instance_eval proc

select("#thing") do

Wat I want to do is evaluate the Proc in the context of el but this
doesn't work because instance_eval accepts a string or a block and not
a Proc object.  I sense Im barking up the wrong tree here entirely but
Im pretty new to this Ruby game so forgive me.

Any suggestions?


Dan W. (Guest)
on 2006-02-10 19:10
(Received via mailing list)
It's okay, I worked it out myself:

el.instance_eval &proc

Just like with starred method arguments...

On 2/10/06, Dan W. <removed_email_address@domain.invalid> wrote:
> Cheers,
> Dan

Dan W.
This topic is locked and can not be replied to.