On 5/26/2011 08:56, jay s. wrote:
> Say we wanted to write our own replace method and not use the replace
> method provided by the String class?  So we want to write a method that
> takes a string object and modifies/mutates that same object and then
> returns it, without creating a copy of that object.

What exactly are you trying to accomplish?  The String class provides
multiple methods to mutate the String instance in various ways, and many
of those methods could be specified in terms of the others, including
replace.  Rather than ask someone to figure out another solution to
which you may respond, "and how do we write our own method_x and not use
the method_x provided by the String class," could you provide some
details about your goals?  What kind of modifications on the String
instance do you want your method to perform?  What methods provided by
the String class are out of bounds (as replace apparently is)?

To me this is sounding a bit like a homework assignment, but maybe it's
not.  In any case, the documentation for the String class is actually
pretty good, so you can probably answer your own question with a little
easy reading:

http://rdoc.info/stdlib/core/1.9.2/String

If I understand what you're really trying to accomplish, the method you
want is definitely listed there.

-Jeremy