From: Ryan Tarpine Date: 2001-09-11T21:34:40+09:00 Subject: [ruby-talk:21124] Re: Proc context ts wrote: >>>>>> "R" == Ryan Tarpine writes: > > R> How does one get a proc to evaluate in the context of the function it > is R> passed to, e.g. like RubyTk? > > #instance_eval > > pigeon% cat b.rb > #!/usr/bin/ruby > class A > def initialize(&block) > @n = 12 > instance_eval(&block) > end > def tt > puts "#{self} : #{@n}" > end > end > > A.new do > puts "block : #@n" > tt > end > pigeon% > > pigeon% b.rb > block : 12 > # : 12 > pigeon% > I assumed it would be as simple as such, but didn't know where to start ;) Thanks! -- self.instance_of? RyanTarpine # => true