From: RK Sentinel Date: 2009-01-22T21:06:35+09:00 Subject: Re: String doesnt auto dup on modification Brian Candler wrote: > RK Sentinel wrote: >> I guess I'll just have to remember not to modify a string I take from >> another class. > > Or as was said earlier on: simply don't use destructive string methods > unless you really have to. Pretend that all strings are frozen. > Yes, I did mention too somewhere to use gsub! etc with caution. Fine in local variables, strings that are not exposed. > He says he modifies some object ...and to his great surprise the object > indeed gets modified. :-) Nice way of putting it. But this happened across objects, and I was wondering whether there was some other solution to the problem which did not require my having to remember not to modify a string taken from elsewhere. -- Posted via http://www.ruby-forum.com/.