From: Eugene Ventimiglia Date: 2001-02-28T23:34:01+09:00 Subject: [ruby-talk:11774] Re: How do I reach members from a Proc? Thank you: This belongs in the Garden! Is there a way to plant it now? --e > -----Original Message----- > From: dave@thomases.com [mailto:dave@thomases.com]On Behalf Of Dave > Thomas > Sent: Wednesday, February 28, 2001 12:56 AM > To: ruby-talk ML; ruby-talk@netlab.co.jp > Subject: [ruby-talk:11748] Re: How do I reach members from a Proc? > > > "Eugene Ventimiglia" writes: > > > Here's a reduced version of what I'm trying to do: > > > class Hello > def install(&p) > @action=p > end > def do > # @action.call > instance_eval(&@action) #<<< > end > def help > puts "in help" > end > end > > h=Hello.new > h.install { > puts "in proc" > help > } > h.do > > > 'instance_eval' effectively evaluates the block in the context of its > receiver (in this case 'h'). Without it, the block is run in it's > original context. > > (http://www.rubycentral.com/book/ref_c_object.html#instance_eval) > > > Regards > > > > Dave >