From: Mike Hall Date: 2004-09-10T04:40:02+09:00 Subject: Re: Q: Should String.upcase! work on a segment of a string? Gavin Sinclair wrote: >> We can assign to a sub-string, so I thought that a bang-method might >> also work on a sub-string. >> s = 'AA11zz' # define a string >> >> > s[4..5].upcase! # try to change part of it >> => "ZZ" # yeah, ok, the new string is changed, >> but... >> > s >> => "AA11zz" # the original string wasn't affected > >s is one object; s[4..5] is another. What you do to the second object is >none of the first's business. I don't understand that... we can outright assign to the substring and it _does_ affect the original string. I agree that pulling out s[4..5] (using it on the RHS) will give me a new object, that's cool. But -- if the string range reference is on the LHS, then it refers to a segment of 's', not some new object. That's what I'm after. If s.upcase! affects s, then it would be cool if s[4..5].upcase! also affected (a portion) of s. But it doesn't, and I guess it won't. OK. Thanks, everyone!