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 Basics (Retired) Ruby Methods Method Returns: Part 1

Create a method called "add" that takes two arguments and returns the sum of two numbers.

Please tell me what I'm doing wrong.

method.rb
def add(a, b)
  return a + b
end

puts add (8, 6)
     add (7, 6)

2 Answers

Dear 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.

def add(a, b) return a + b end