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 trialShaimoom Newaz
7,219 PointsParenthesis vs Brackets vs Curly Brackets
Hi - Is there a rule of thumb regarding when to use each character?
1 Answer
Luke Glazebrook
13,564 PointsHi!
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
Shaimoom Newaz
7,219 PointsShaimoom Newaz
7,219 PointsThanks for the examples, Luke. Starting to make more sense.
Luke Glazebrook
13,564 PointsLuke Glazebrook
13,564 PointsAwesome! Glad I managed to help you out.