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 The Solution

Error

def area(length, width) length * width end

def perimeter(length, width) 2* (length + width) end

puts area (2, 3) puts perimeter (2, 4)

I have written this code and saved it in the workspace and every time I get back this message:

treehouse:~/workspace$ ruby rectangle.rb
rectangle.rb:9: syntax error, unexpected ',', expecting ')'
puts area (2, 3)

Can't see what i have done wrong :/

1 Answer

Lee Vaughn
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Lee Vaughn
Treehouse Teacher

Hi Simon!

You have probably already figured this out but even so, I wanted to reply in case someone else who runs into a similar issue might see this.

The error is caused by a small issue with the syntax of how you are trying to use the puts method. Remember you can use methods like puts with or without parenthesis but that will have a slight difference on how the code is formatted. When you use the parens there would be no space between the method and the arguments, like puts area(5, 2). But if you don't use the parens there would be a space, like puts area 5,2. What is throwing you off is that you are using parens but also including the space. Just remove that space and you will be all good.

Also, just a general tip for tracking down these types of issues. In the error message, it includes rectangle.rb:9, which is points to line of code where the error is originating. Now the problem won't always be on that exact line (it is in this case) but that is a good place to start looking as the error will almost always be on that line or before. :thumbsup:

Happy coding!