On 6/5/06, email@example.com firstname.lastname@example.org wrote:
Maybe because that would render #respond_to? essentially useless
In my example where the object responds to everything, sure. It was
just an example though, and of course not every class is going to act
I guess the key is to write a predicate and stick it in both methods.
def method_missing(m, *args)
valid_method?(m) ? m.to_s : super
Of course it’s not particularly useful here, but you could change
[ :foo, :bar ].include? m
Guess I just thought Ruby would automatically pick it up. However, I
don’t see how it’d be able to, short of creating a copy of the object
in memory and calling the method on the object to see if it returns a
result. If the copy gives a method missing error, then respond_to?
would return false. Obviously it would suck to create a copy and
actually call the method just to see if an object responds to it.