Arguments and Parentheses

Learn the conventions for using parentheses when passing arguments to methods.

Notice how we’ve been calling so many of the methods in previous lessons by enclosing the arguments in parentheses—for example, add_two(3). But puts is also a method, and we’re quick to pass an argument to it without enclosing it in parentheses. For example, to print 5, we write puts 5.

That’s right. When we define or call (execute, use) a method, we can omit the parentheses.

So, these lines mean the same:

Create a free account to access the full course.

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