From: "Mauricio Fernández" Date: 2004-05-02T22:10:54+09:00 Subject: Re: Why no Proc##[]=() ? Why no Proc##replace() ? On Sun, May 02, 2004 at 05:18:09PM +0900, Jean-Hugues ROBERT wrote: > There are other ways to do this of course, without replace: > p = proc { @x ||= long_method } > or (needed if result can be nil) > p = proc { @x = long_method unless defined? @x; @x } It seems to me that you're assuming @x is an instance variable of the Proc object, which it is not: def foo; 1 end # =>nil p = proc { @x ||= foo } # =># @x # => (irb):3: warning: instance variable @x not initialized # =>nil p[] # =>1 @x # =>1 -- Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com 'Ooohh.. "FreeBSD is faster over loopback, when compared to Linux over the wire". Film at 11.' -- Linus Torvalds