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 Ruby Syntax Method Return Values

Mika Laakso
Mika Laakso
4,222 Points

wrong number of arguments (given 0, expected 2)

What is wrong with my code? I thought these arguments would return three and five...

methods.rb
def three a, b
  return a + b

end

def five c,d
  return c-d

end

three(1, 2)
five(7, 2)

2 Answers

Manish Giri
Manish Giri
16,266 Points

The challenge you've linked to just asks to create functions that return 3 and 5 respectively.

def three
  3
end

def five
  5
end

Also, unless explicitly stated, you aren't required to call your functions.

Mika Laakso
Mika Laakso
4,222 Points

Thank you, Manish,

I tried almost the same code before but I had 3 on the same line of three and 5 five on the same line of five so it gave a syntax error. Thank you. Now I can move forward.