D
Derek Chesterfield
I am trying to convince myself that Ruby is fully OO [I'm not
suggesting it isn't!].
So writing 'object.method' sends a message 'method' to 'object', and
writing 'method' implies sending to self. So how come the result of
'puts' is different to the result of 'self.puts'?
I'm sure this is a semantic question, but I can't figure it out! How
come 'self.puts' find the private puts method of Object, whereas
'puts' finds Kernel.puts?
suggesting it isn't!].
So writing 'object.method' sends a message 'method' to 'object', and
writing 'method' implies sending to self. So how come the result of
'puts' is different to the result of 'self.puts'?
$ irb
irb(main):001:0> puts "hello"
hello
=> nil
irb(main):002:0> self.puts "hello"
NoMethodError: private method `puts' called for main:Object
from (irb):2
I'm sure this is a semantic question, but I can't figure it out! How
come 'self.puts' find the private puts method of Object, whereas
'puts' finds Kernel.puts?