# Instance\_eva()l-ing a proc with parameters

**URL:** <https://rubytalk.org/t/instance-eva-l-ing-a-proc-with-parameters/31540>\
**Category:** ruby-talk\
**Created:** [2 October 2006 19:15 UTC](https://rubytalk.org/t/instance-eva-l-ing-a-proc-with-parameters/31540 "2006-10-02T19:15:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gennady\_Bystritsky1](https://avatars.discourse-cdn.com/v4/letter/g/65b543/32.png) [@Gennady\_Bystritsky1](https://rubytalk.org/u/Gennady_Bystritsky1)\
**Post date:** [2 October 2006 19:15 UTC](https://rubytalk.org/t/instance-eva-l-ing-a-proc-with-parameters/31540/1 "2006-10-02T19:15:59Z")

</div>

Logan Capaldo wrote:

> **···**
>
> > On Tue, Oct 03, 2006 at 01:35:48AM +0900, Gennady Bystritsky wrote:
> > 
> > > Dear friends,
> > > 
> > > I need to evaluate a proc within an instance context and would like  
> > > to pass it a parameter. The only straight forward way I found is to  
> > > use instance\_eval(), however it does not allow to pass parameters to  
> > > a proc, only the instance itself is passed as a single parameter:
> > 
> > Google for instance\_exec, there are various and sundry  
> > implementations, including one built into rails.
> > 
> > [http://eigenclass.org/hiki.rb?instance\_exec](http://eigenclass.org/hiki.rb?instance_exec) has various  
> > implementations and their respective strengths and weaknesses. Or you  
> > can  
> > just use ruby  
> > 1.9 where it's part of the core.
> 
> Thanks a lot, Logan. That's exactly what I need and what I have missed  
> completely here on the list when the discussion first came up.
> 
> It looks like I am better off sticking to my define\_method() custom  
> solution for now, as instance\_exec() uses the same approach anyway.
> 
> Thanks again,  
> Gennady.
