From: SonOfLilit Date: 2007-02-17T02:47:50+09:00 Subject: Re: Oppinions on RCR for dup on immutable classes ------=_Part_7056_11175599.1171648058883 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 2/16/07, Gregory Brown wrote: > > On 2/16/07, Stefan Rusterholz wrote: > >> a = 3 > => 3 > >> b = a.dup rescue a > => 3 > >> b > => 3 > > What's so bad about that? > > When you use #dup not knowing about this complication, never dup a Fixnum in testing, but happen to dup one in production - e.g. in a library released to the public. Ruby is always about principle-of-least-surprise and this behavior really surprised me when I first read about it non-list (I've stayed away from object copies in MY code, because it all seems so hacky and arcane to me... Truns out it was a good idea) ------=_Part_7056_11175599.1171648058883--