From: James Gray Date: 2008-10-14T04:42:59+09:00 Subject: Re: status of cache in Memoizable On Oct 13, 2008, at 2:17 PM, matt neuburg wrote: > There's one thing happening here I don't understand. Let's say you > don't > supply a value for the "cache" parameter. So the cache is simply > Hash.new. But where does this Hash.new live? It isn't assigned to a > variable name so what keeps it alive? It works, but how? That variable is kept alive thanks to the magic of closures. The block passed to define_method() references the variable, so it will exist as long as that closure does. Think of it as private storage that only that block uses. James Edward Gray II