From: Robert Klemme Date: 2009-01-23T06:28:23+09:00 Subject: Re: String doesnt auto dup on modification On 22.01.2009 15:11, RK Sentinel wrote: > As and when i discover such bugs in my code, I start adding dup(), and > yes sometimes these lines bomb when another datatype is passed (I had > asked this in a thread recently: respond_to? dup was passing, but the > dup was failing). > Anyway, i realize its more my incompetence, and i must be careful with > destructive methods, but I just thought maybe there's some other way to > do this, so i am not leaving it to my memory. I would not call this "incompetence": we live and learn. Basically this is a typical trade off issue: you trade efficiency (no copy) for safety (no aliasing). As often with trade offs there is no clear 100% rule which exactly tells you what is *always* correct. Instead you have to think about it - when creating something like a library even more so - and then deliberately decide which way you go. Kind regards robert -- remember.guy do |as, often| as.you_can - without end