From: Gregory Brown Date: 2009-01-27T01:18:32+09:00 Subject: Re: Question about BlankSlate.reveal On Mon, Jan 26, 2009 at 8:55 AM, Robert Klemme wrote: > I do not really see caching that extends the instance on which #reveal > was invoked. There is actually one closure per instance (more > correctly: one closure per call of reveal) and so no global cache. > > Where exactly is your problem? I think you missed that the local variable was at the class level. >> class A >> a = nil >> define_method :foo do ?> a ||= self >> end >> end => # >> A.new.foo => # >> A.new.foo => # >> A.new.foo => # >> A.new.foo => # But I think I have a suitable fix: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/325826 What do you think? -greg -- Technical Blaag at: http://blog.majesticseacreature.com Non-tech stuff at: http://metametta.blogspot.com "Ruby Best Practices" Book now in O'Reilly Roughcuts: http://rubybestpractices.com