Passing Arguments

Learn how to pass arguments to a method in Ruby.

We'll cover the following

Extra information needed

An object occasionally needs extra information to do what we ask.

For example, the String class defines the delete method, which returns another string with some characters deleted. To do so, it needs to know which characters we’d like to remove.

We can pass things by appending parentheses () to the method call (the name). We can then include the extra bit of information needed (in our case, another string) inside the parentheses, like so:

Create a free account to access the full course.

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