From: Florian Gilcher Date: 2012-12-24T09:16:23+09:00 Subject: Re: POLS and string-handling On Dec 24, 2012, at 12:55 AM, Paul Magnussen wrote: > Thanks for all the replies. I notice also that I can force changing of > the value (as opposed to the reference) by substituting a trivial > expression for the right-hand side of the assignment, e.g. > > # g) Expression > > myStringA = "Fred Shufflebotham" > myStringB = myStringA + "" > myStringB[0,4] = "Bert" > > => myStringA = "Fred Shufflebotham" > => myStringB = "Bert Shufflebotham" > > But of course it's an utter kludge. Is there really no more elegant > way? Sure, either use a Method that doesn't mutate the string but returns a new one instead, like #sub and #gsub. e.g.: myStringA.sub("Fred", "Bert") myStringA.sub(/.{4}/, "Bert") Or properly clone the string before mutating it: myStringB = myStringA.clone myStringB[0,4] = "Bert" Regards, Florian