On Nov 11, 2007 5:29 AM, Matthew Boeh <mboeh / desperance.net> wrote:
>
> On Sun, Nov 11, 2007 at 07:06:44PM +0900, Jordi wrote:

> > IIRC, in Ruby everything is message sending to objects even in the
> > disguise of Object#method, at least conceptually.
> >
>
> Conceptually, yes. But as far as I can tell, Object#respond_to? is effectively
> equivalent to:
>
>   def respond_to?(message)
>     !!method(message) rescue false
>   end


Oh I hope not.

class PresidentOfTheUnitedStates
  def trigger_global_thermonuclear_war
      # code to end civilization as we know it.
  end
end

PresidentOfTheUnitedStates.new.respond_to?(:trigger_global_thermonuclear_war)


> in that Object#method_missing doesn't have any effect on it. So there is a
> concrete distinction between messages that map directly to methods and
> messages handled by method_missing.

I may misunderstand you, but if respond_to? really were equivalent to
code above, then providing a response via method_missing WOULD affect
it.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/