Calling Methods

Calling Methods

Calling a method sends a message to an object so it can perform some work.

In ruby you send a message to an object like this:

my_method()

Note that the parenthesis are optional:

my_method

Except when there is difference between using and omitting parentheses, this document uses parenthesis when arguments are present to avoid confusion.

This section only covers calling methods. See also the syntax documentation on defining methods.

Receiver

self is the default receiver. If you don't specify any receiver self will be used. To specify a receiver use .:

my_object.my_method

This sends the my_method message to my_object<