From: jeremy Ruten Date: 2010-08-12T08:52:57+09:00 Subject: Re: Can't change the value of self - II You can use the #replace method to do that sort of thing: self.replace "Help! Oh, well, I'm saved!" This method is defined in classes String, Hash, Array, and Set, and works the same way in each one. jeremy On Wed, Aug 11, 2010 at 5:44 PM, Ralph Shnelvar wrote: > I'm still not "getting it." > > Consider > > - - - > class DirectoryString < String >  def initialize(arg) >    super arg >  end > >  def convert_forward_slash_to_back_slash >    self.gsub(/\//, "\\") >  end > >  def convert_forward_slash_to_back_slash! >    self.gsub!(/\//, "\\") >  end > >  def remove_trailing_backslash_if_any >    self.chomp("\\") >  end > >  def remove_trailing_backslash_if_any! >    self.chomp!("\\") >  end > >  def append_trailing_backslash_if_needed >    remove_trailing_backslash_if_any + "\\" >  end > >  def append_trailing_backslash_if_needed! >    # ??????? What do I do here ??????? ... The following is illegal >    self = "Help!" >  end > end > > - - - > > > The only thing I can think of is converting from the standard IS_A (Inheritance) to a HAS_A (create a member variable). > > If I do the latter, above, I will have to create a ton of simple "forwarding" messages. > > What's the Ruby way of doing this sort of thing?