On Jan 5, 2008 4:32 PM, Gary Wright <gwtmp01 / mac.com> wrote: > Actually it is a bit different. Monkey patching is just adding > methods to classes. Fixnum and String in your examples. > > Instance variables on Fixnums (or Symbols or Nil) is different. > It is a good example of uniformity in Ruby but I'm hard pressed > to think of a nice use case for the feature. > > Gary Wright You can use it to cache the result of method calls. class Fixnum def factorial @factorial ||= self * (self-1).factorial end end 0.instance_variable_set('@factorial',1)