Ruby Object Model Screencasts

Here is one alternative to the Memoize module from example 9 in episode 5.

module Memoize
 
  def remember(method, &block)
    memory = {}
    define_method(method) do |*args|
      return memory[args] if memory.has_key?(args)
      memory[args] = block.call(*args)
    end    
  end
 
end
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License