From: RK Sentinel Date: 2009-01-22T14:05:58+09:00 Subject: Re: String doesnt auto dup on modification Tom Cloyd wrote: > Stefan Lang wrote: >>> aware of freeze(). >> >> assertions are, habitually duping strings is a bad practice, IMO. >> >> Stefan >> >> >> > If this is an utterly dumb question, just ignore it. However, I AM > perplexed by this response. Here's why: i agree with you. I have objects that get a string, process/clean it for printing/display. (That is the whole purpose of centralizing data and behaviour into classes.) Remembering I must not modify it is a big mental overhead and results in strange things that I spend a lot of time tracking, till I find out --- oh no the string got mutated over there. Now I must start dup()'ing it -- okay, where all should I dup it ? To the previous poster - yes, one does not have to use dup. One can create a new string by changing the method from say gsub! to just gsub() and take the return value. I include such situations when i say dup(). -- Posted via http://www.ruby-forum.com/.