From: Ryan Tarpine Date: 2001-09-16T01:18:44+09:00 Subject: [ruby-talk:21222] Re: Call Proc in different context Anders Johannsen wrote: > Object.instance_eval is useful for evaluation 'raw' source and blocks in > a different context. > > How -- if at all possible -- is this done with a Proc? > > Regards, > Anders Johannsen > I just asked the same basic question within the past week or so, actually. Use instance_eval(&procvar), e.g. class Foo def initialize @var = 1 end def call(p) instance_eval(&p) end end p = proc { p @var } foo = Foo.new foo.call(p) # => prints '1' -- self.instance_of? RyanTarpine # => true