From: nobu.nokada@... Date: 2005-09-07T15:21:47+09:00 Subject: Re: memoize Hi, At Wed, 7 Sep 2005 14:41:28 +0900, horndude77@gmail.com wrote in [ruby-talk:155156]: > - Is there a way to do this without an eval to speed it up? > - Make this work on the class level. module Kernel def memoize(name) m = method(name) cache = {} (class << self; self; end).class_eval do define_method(name) do |*args| cache[args] ||= m.call(*args) end end end end -- Nobu Nakada