From: Robert Klemme Date: 2009-01-23T06:28:24+09:00 Subject: Re: String doesnt auto dup on modification On 22.01.2009 12:23, 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. > > You can enforce this easily enough in your unit tests: e.g. you could > pass in strings that really are frozen, and check that your code still > works :-) Well, this is only half of the story: it does not save you from outside code changing the instance under your hands. Aliasing works both ways, i.e. you can screw up the receiver but also the caller. :-) Cheers robert -- remember.guy do |as, often| as.you_can - without end