Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Ruby Objects and Classes Variables and Methods Methods

John Bamberg
John Bamberg
9,774 Points


Why add () after full_name method?

3 Answers

The parenthesis after a method is what indicates to the interpreter that it is a method, and also indicates that you are calling it into action.

In Ruby parenthesis after method call are redundant.

Here are two ways to define a method. Both are the same. The first is the original way, the second is the common way.

def full_name() ... end

def full_name ... end

Note the (). The parenthesis mark that it is a function (as opposed to a variable). However in Ruby, parentheses can usually be omitted. It makes the text easier to read.

These are also the same: puts name.full_name() puts name.full_name

To improve clarity, some people will include () to make it extra clear that it is a function.