From: Robert Klemme Date: 2007-06-05T21:30:22+09:00 Subject: Re: Writing method "change!" for String On 05.06.2007 14:16, Mike wrote: > Hi, > > I'm trying to write simple method to change internal value of > String class: > > class String > def change! > self="0" if self.downcase=="myvalue1" > self="1" if self.downcase=="myvalue2" > self > end > end > > test="myvalue1" > test.change! > p test > > It should just change value of string to what I want. But I get error: > "Can't change the value of self". > How do I proceed? You don't. Just use String#replace. Btw, what are you trying to achieve? Kind regards robert