Quantcast
Channel: In Ruby what does the "receiver" refer to? - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Cameron Pope for In Ruby what does the "receiver" refer to?

$
0
0

In Ruby (and other languages that take inspiration from SmallTalk) objects are thought of as sending and receiving 'messages'.

In Ruby, Object, the base class of everything, has a send method: Object.send For example:

class Klass  def hello"Hello!"  endendk = Klass.newk.send :hello     #=> "Hello!"k.hello           #=> "Hello!"

In both of these cases k is the receiver of the 'hello' message.


Viewing all articles
Browse latest Browse all 4

Trending Articles