From: Brian Candler Date: 2007-05-05T03:32:06+09:00 Subject: Re: Top-level On Fri, May 04, 2007 at 08:50:01PM +0900, Lucas Holland wrote: > Ah, I see. Okay, so I can call puts like a 'standalone function' because > of the following: When I run a Ruby script, an object called 'main' is > instanciated. It's an instance of the Object class. The Object class > includes puts via a mixin from the Kernel module. It's thus like a > private instance method of Object. > > When I call puts, I don't specify a receiver. That's why Ruby takes self > as the receiver. At the top level, self refers to the main object. So my > call is basically main.puts Roughly. Except you can't actually call it that way, because it's private. > puts is a *private* instance method of Object, so why can I call it from > an instance (main being the instance in this case)? 'Private' means it can *only* be called on self, and only using the implicit form (where you don't specify a receiver). HTH, Brian.