From: Sean O'Dell Date: 2004-05-28T07:15:59+09:00 Subject: Re: true.respond_to?("clone") On Thursday 27 May 2004 15:05, David A. Black wrote: > Hi -- > > On Fri, 28 May 2004, Sean O'Dell wrote: > > On Thursday 27 May 2004 14:24, Hal Fulton wrote: > > > Sean O'Dell wrote: > > > > TrueClass responds to "clone" but when you call it, the method just > > > > throws an error that says "can't clone TrueClass." How can I tell > > > > when an objects support a given method if they implement them but > > > > then raise exceptions? Is there some other methodology I should use? > > > > > > Interesting question. I suppose you could always catch the exception > > > and then set your own flag that says you can't clone. > > > > That sort of makes respond_to? less functional than advertised. > > It's just being very literal. > > > > This raises the question in my mind of whether the clone method should > > > simply be removed from such classes. > > > > My feeling is, it should be removed. I would think that the rule of > > thumb is "if it respond_to?'s, it is implemented." > > What about NotImplementedError? :-) Why have respond_to? at all then? Why not just catch NotImplementedError everywhere you need to check an object before trying to call a method? Sean O'Dell