Java – Is the “caller” in Java the same as the “receiver” in Ruby


If I say


In Java, object x is "calling" the method it contains.

In Ruby, object x is "receiving" the method it contains.

Is this just different terminology for expressing the same idea or is there a fundamental difference in ideology here?

Coming from Java I find Ruby's "receiver" idea quite baffling. Perhaps someone could explain this in relation to Java?

Best Solution

In your example x is not calling hello(). Whatever object contains that snippet is "calling" (i.e., it's the "caller"). In Java, x can be referred to as the receiver; it is receiving the call to the hello() method.