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.
0727907ae68db2e8ebc1ea1b01f00d69?d=identicon&s=25 Dan Webb (Guest)
on 2006-02-10 16: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?


0727907ae68db2e8ebc1ea1b01f00d69?d=identicon&s=25 Dan Webb (Guest)
on 2006-02-10 18: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 Webb <> wrote:
> Cheers,
> Dan

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