Calling Methods

Learn how to call an object's methods in Ruby.

We'll cover the following

Calling methods

In Ruby, methods that are defined on objects can be used by adding a dot and then the method name, like so:

object.method

That essentially instructs an object to perform the method’s behavior.

This is known as calling a method.

For example, the String class defines methods like:

  • upcase (convert the object to uppercase)
  • downcase (convert the object to lowercase)
  • length (returns the string’s length)

Here’s how we can call them:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy