2009/4/22 Tom Cloyd <tomcloyd / comcast.net>:
> Thanks. Does just fine - now that I know about it. Handy!
>
> t.
>
> Chris Kottom wrote:
>>
>> Object#respond_to? doesn't do it for you?

This is unsafe:

irb(main):001:0> o = Object.new
=> #<Object:0x10171bb8>
irb(main):002:0> def o.method_missing(s,*a,&b) s == :foo ? "yes" : super end
=> nil
irb(main):003:0> o.respond_to? :foo
=> false
irb(main):004:0> o.respond_to? "foo"
=> false
irb(main):005:0> o.foo
=> "yes"
irb(main):006:0>

The best approach is to actually invoke the method and deal with
exceptions IMHO (-> duck typing).

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/