Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Objects and Classes Variables and Methods Methods

John Bamberg
John Bamberg
9,774 Points

Parenthesis

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.

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.