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 trialEric McGee
1,324 PointsCreate a method called "add" that takes two arguments and returns the sum of two numbers.
Please tell me what I'm doing wrong.
def add(a, b)
return a + b
end
puts add (8, 6)
add (7, 6)
2 Answers
Yasin Khan
25,279 PointsDear Erin,
Your code has one extra space causing it to fail.
puts add (8, 6)
should be:
puts add(8, 6)
Notice there is no space between "add" (the method) and the leading left bracket before the arguments are passed in. This works perfectly for me.
Hope that helps.
Thanks.
Annie Scott
27,613 Pointsdef add(a, b) return a + b end