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 trialJulia Thalita Da Silva Carrilo
1,347 PointsWhen go run methods show syntax error!
This is my code:
def add(a, b) puts "Adding #{a} and #{b}:" puts a + b end
add(2, 3) add (5, 5) add (6, 6)
This is the error:
treehouse:~/workspace$ ruby methods.rb
methods.rb:7: syntax error, unexpected ',', expecting ')'
add (5, 5)
^
3 Answers
Raymond Erni
Courses Plus Student 4,052 Pointsthis should work just the way you want , i which i could explain it to you in the perfect workds but i am not a teacher. but hope you understand. you need to have a place holder.
def add(a, b) puts "Adding #{a} and #{b}:" puts c = a + b end
add(2,3) add(5,5) add(6,6)
Raymond Erni
Courses Plus Student 4,052 Pointsyou have a result like this: ubuntu@ubuntu:~/community$ ruby add.rb Adding 2 and 3: 5 Adding 5 and 5: 10 Adding 6 and 6: 12 ubuntu@ubuntu:~/community$
Raymond Erni
Courses Plus Student 4,052 PointsMake sure the "puts" are on different lines . its very important ***** puts "Adding #{a} and #{b}:" ***** ***** puts c = a + b ******
Julia Thalita Da Silva Carrilo
1,347 PointsI did.. sounds like a problem with treehouse.. so I'm stock!
Julia Thalita Da Silva Carrilo
1,347 PointsJulia Thalita Da Silva Carrilo
1,347 PointsDidnt work.
treehouse:~/workspace$ ruby methods.rb
methods.rb:5: syntax error, unexpected tIDENTIFIER, exp ecting end-of-input
add(2,3) add(5,5) add(6,6)
^