Module: Memoize
- Defined in:
- lib/numb.rb
Instance Method Summary collapse
Instance Method Details
#memoize(sym) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/numb.rb', line 3 def memoize(sym) aka = "_#{sym}".to_sym alias_method aka, sym @@NUMB ||= {} Integer.send(:define_method, sym) do |*args| @@NUMB[[self, sym, args]] ||= send(aka, *args) end end |