Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the "caller" in Java the same as the "receiver" in Ruby?

If I say

x.hello()

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?

like image 300
lorz Avatar asked May 27 '09 17:05

lorz


People also ask

What is a caller in Java?

"caller" means the code which calls the method.

What is a receiver in Java?

Interface Receiver A Receiver receives MidiEvent objects and typically does something useful in response, such as interpreting them to generate sound or raw MIDI output. Common MIDI receivers include synthesizers and MIDI Out ports.


1 Answers

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.

like image 147
erickson Avatar answered Sep 25 '22 23:09

erickson