L
Lucas Holland
Hello everyone!
I'm currently diving a bit deeper into Ruby and I've already asked this
question in the IRC (the folks there have been great I think I'm getting
it 50%). The question's about top-level methods:
Let's take puts as an example. Puts is inside of the Kernel module,
which gets mixed into the Object class. So essentially, it's a private
method of Object. When I call puts, I don't specify a receiver, so self
is assumed (I think so). In this case self refers to main, an instance
of Object, automatically created. So, I'm really calling main.puts. main
is an instance of Object, so why is it able to call private methods of
Object?
Help would be greatly appreciated!
Lucas
I'm currently diving a bit deeper into Ruby and I've already asked this
question in the IRC (the folks there have been great I think I'm getting
it 50%). The question's about top-level methods:
Let's take puts as an example. Puts is inside of the Kernel module,
which gets mixed into the Object class. So essentially, it's a private
method of Object. When I call puts, I don't specify a receiver, so self
is assumed (I think so). In this case self refers to main, an instance
of Object, automatically created. So, I'm really calling main.puts. main
is an instance of Object, so why is it able to call private methods of
Object?
Help would be greatly appreciated!
Lucas