From: MenTaLguY Date: 2001-11-24T05:55:20+09:00 Subject: [ruby-talk:26258] Re: adding instance variables to an existing class. > How might I add some instance variables to an existing class, such > as String, and have them initialized properly? Two possibilities come to mind immediately: class String attr_writer :pos def pos @pos = 0 if not instance_variables.include? "@pos" @pos end end OR... class String attr_writer :pos def pos @pos = 0 class << self alias_method :pos, :_pos end @pos end def _pos ; @pos ; end end That does depend on you always using the accessor, however. -mental