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?
"caller" means the code which calls the method.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With