From: Josh Cheek Date: 2010-11-13T15:23:13+09:00 Subject: Re: what's an object? --0016e6465148c1e7d30494e93d97 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Nov 12, 2010 at 10:35 PM, Chad Perrin wrote: > > Why should you be able to do puts(3), if you think we should not be able > to do foo(3)? > > Because puts(3) is shorthand for "send the object 'Kernel' the message 'puts' with the parameter '3'" but foo(3) is shorthand for "send the object 'foo' no message at all with the argument 3" That doesn't work because it is not consistent with Ruby's object model. In other words, the difference is this: Kernel.send "puts" , 3 foo.send "" , 3 They may look the same the way you formatted their syntax, but they are completely different. Putting (3) after puts is not what invoked it. Sending it to the object Kernel is what invoked it. Likewise, putting (3) after foo will not invoke foo, rather, sending call to the object foo will invoke it. I can't think of any way to reconcile such a belief with anything anywhere in Ruby, and your puts example only appears to be an exception because you formatted it deceptively. From your table, its not that puts.call(3) and foo(3) fail to work, its that they don't even make sense. puts is invoked, it returns a value. You aren't sending call to puts, you are sending it to nil, the object that puts returns. You are just using tricks of syntax to be ambiguous. Make it Kernel.puts().call(3) and it is explicit. Make it self.foo(3) and it is explicit, it is a message to self, not to foo. --0016e6465148c1e7d30494e93d97--