On 5/4/07, Lucas Holland <hollandlucas / gmail.com> wrote:
> Okay, so I can call puts because I am calling it on self (and self
> refers to main, doesn't it?)?

Yes, although the fact that self in this case refers to main is pretty
much irrelevant.

In general, self always refers to SOME object, in top-level code that
object is the top-level object or main.

In an instance method, self is the instance which received the message.

In a class method, self is the class, but Class is a subclass of
Object so classes also inherit the methods of Object, including the
(private) methods defined by Kernel which is included by Object.  The
only time you can't if if a class has specifically undefined the
method.

I'll refrain from talking about BasicObject in ruby1.9 unless asked.

-- 
Rick DeNatale

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