From: matz@... (Yukihiro Matsumoto) Date: 2002-05-03T02:00:31+09:00 Subject: Re: A scoping issue Hi, In message "A scoping issue" on 02/05/02, Harry Ohlsen writes: |The problem is that, of course, the reference to @x |assumes it's an instance variable of class A, rather |than the one from class B, in the outer scope. | |Is there some way I can get the block passed to the |A.new to end up with the @x from the instance of B |that I'm constructing? class A def initialize(block) @code = block end def execute @code.call end end class B def initialize @x = 123 a = A.new(proc { puts @x }) a.execute end end B.new prints 123 as you may expect. matz.