L Forrister <L4 / stetson.net> writes:

> which works fine.  So my question is why does:
>       self[0..-1] = @rs

Think of this as:

    self.[](0..-1, @rs)

You're making a method call on self, calling the [] method.  This is
similar to my suggestion to use String#replace.


> work?  While:
>       self = @rs
> does not.

For various reasons, you can't assign to the self object in Ruby.


> Also, what exactly does dup.method do (suggested as a stupid way by
> Guy Decoux)?

That is the same as self.dup.method.  dup will duplicate an object
(creating a new copy).  dup.method will duplicate the object, then
call method on the duplicate copy.


-- 
matt