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 Collections Build a Grocery List Program Build a Grocery List Program: Part 4

Parenthesis vs Brackets vs Curly Brackets

Hi - Is there a rule of thumb regarding when to use each character?

1 Answer

Hi!

Yeah, you are right in thinking that. You are supposed to use curly braces and also parentheses in specific places in your program.

For example, parentheses are used after method names so that you can supply the method some parameters (variables to work with).

def hello()

Curly braces on the other hand are used to segment off code and define it's scope.

def hello() {

}

If you have any questions about any of the topics I covered above then don't hesitate to ask them.

-Luke

Thanks for the examples, Luke. Starting to make more sense.

Awesome! Glad I managed to help you out.