On May 30, 2:18=A0pm, Mark Wilden <m... / mwilden.com> wrote:
> On May 29, 2008, at 3:37 AM, David A. Black wrote:
> > You can ask it what its class is, what its ancestors are,
> > what methods it responds to, and so forth... but in the end, you hit
> > the singularity: the sending of the message.
>
> However, an object's class and ancestors _determine_ what messages an =A0
> object responds to. That's what they're there for - to hold message =A0
> maps

But in Ruby knowing an objects class and an ancestors is not
sufficient, as the object can have methods added to it's eigenclass as
well. More importantly, it can have methods _removed_ by calling
#undef in it's eigenclass, which means that if you want to call #foo,
checking an objects class is not sufficient - the object might be the
only one of it's class not to answer to #foo.

Furthermore, the object may answer to a message by implementing
#method_missing.

The only guaranteed way of knowing whether or not an object answers to
a message in Ruby is to try to send it.




Vidar