From: Marcello Barnaba Date: 2007-02-18T21:54:43+09:00 Subject: Re: Oppinions on RCR for dup on immutable classes Hi, On Sunday 18 February 2007 13:16, SonOfLilit wrote: > Say, why not just define Object#mutable? and solve the issue of not > knowing if dup is possible or not? In my opinion, this exposes at the ruby level an implementation detail that pollutes the language design, and you must add it to the "weird things you should remember". Please, compare def a obj = some_method raise 'hey!' unless obj.mutable? do_stuff obj.dup rescue SomeMethodError pull_out_the_power_cord end to def a do_stuff some_method.dup rescue SomeMethodError pull_out_the_power_cord rescue TypeError raise 'hey!' end I think that the whole design is clear and makes sense, you can call a method, and you should catch exceptions, if you care about them. Or let them stop execution, if needed. > Sure, it only works to tell you about one possible reason it's not, > but it seems like a good workaround, far better than, say, duping just > to check. Why should "dup" behave differently than all the other methods that raise exceptions when something exceptional happens? :) my 0.02c -- pub 1024D/8D2787EF 723C 7CA3 3C19 2ACE 6E20 9CC1 9956 EB3C 8D27 87EF