From: Sean O'Halpin Date: 2005-11-04T07:33:13+09:00 Subject: Re: memoize and yaml On 11/3/05, Daniel Berger wrote: > Would folks like both options? memoize_all or something? Or just leave it alone? With a slight adjustment, Florian's version can be used at the top level too (at the cost of the instance variable @cache in main): module Memoize def memoize(name) name = name.to_sym if self.to_s == "main" old_method = class<[10, 20], [:t_memo, 7, 8]=>[70, 80]} {[:t_memo, 1, 2]=>[20, 40], [:t_memo, 7, 8]=>[140, 160]} calculating [1, 2, 3] [5, 10, 15] [5, 10, 15] calculating [7, 8] [35, 40] {[:t_memo, 7, 8]=>[35, 40], [:t_memo, 1, 2, 3]=>[5, 10, 15]} Regards, Sean