On 2/17/07, Gregory Brown <gregory.t.brown / gmail.com> wrote:
> On 2/17/07, Stefan Rusterholz <apeiros / gmx.net> wrote:
>
> > My issue is that I can't test that. I can only try and catch the
> > exception. With dup that's not too terrible as it doesn't have
> > side-effects. Still in my oppinion having to run code to see what
> > happens is not a clean behaviour.
>
> Oh, good point.
>
> >> 1.respond_to?(:dup)
> => true
>
> Then you need to rescue the exception.
>
> If you *really* need this behaviour, you could just stick it in a file
> somewhere and require it.
>
> >> class Fixnum
> >>   undef :dup
> >> end
> => nil
> >> 2.dup
> NoMethodError: undefined method `dup' for 2:Fixnum
>
Oh no, you don't wanna do that: What if you're a library and a user
assumes :dup is defined? What if you use a library that assumes it and
don't know about it?
>
> BTW, Matz, the only difference I suppose is that by having a
> NoMethodError, we could make use of respond_to? as a check, but I
> don't know if I think it's such a big deal that I'd be in support of a
> RCR.
>
>