From: "Jan E." Date: 2013-01-04T11:46:18+09:00 Subject: Re: respond_to_missing? Hi, "respond_to_missing?" makes "respond_to?" fit for dynamic methods defined by "method_missing". Normally, an object wouldn't know if it can respond to a dynamic method call: #----------------------- class A def method_missing name, *args if name == :say_hi puts 'Hi there!' else raise NoMethodError end end end a = A.new a.say_hi # "Hi there!" puts a.respond_to? :say_hi # => false #----------------------- But if you define "respond_to_missing?", you can work around this problem: #----------------------- class A def method_missing name, *args if name == :say_hi puts 'Hi there!' else raise NoMethodError end end def respond_to_missing? name, include_private name == :say_hi end end a = A.new a.say_hi # "Hi there!" puts a.respond_to? :say_hi # => true #----------------------- -- Posted via http://www.ruby-forum.com/.