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

Kristen Kerchhoff
Kristen Kerchhoff
1,895 Points

Methods working locally but in online editor

When I run the methods in this file locally the correct numbers are returned.

However when I run this in the online editor as part of a challenge task it returns "wrong number of arguments (given 0, expected 2)"

Could someone please advise what the correct format should look like?

def three(length, width)
    return length + width

def five(length, width)
    return length - width

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

1 Answer

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Hi Kristen,

While the code above is correct in syntax, it is not what the Challenge is asking for. I'm not sure where you are getting the code from, but instructions for Code Challenges need to be followed exactly or the task will fail with a Bummer!.

You are getting that error because there are supposed to be no arguments for the methods, but you have two in both. The instructions simply say to:

Define a method named three that returns the number 3. Also define a method named five that returns the number 5.

The instructions say nothing about calculations or even calling the methods, nor do they say anything about arguments.

A good rule to remember is: "If the instructions don't ask for it... don't do it." :smirk:

I feel you just really over thought this one. The methods just needs to be simplified:

def three()
  return 3

def five()
  return 5

Other than that... Nice work on the method syntax! :) :dizzy:

Jay McGavren
Jay McGavren
Treehouse Teacher

This challenge seems to have been confusing a lot of people. Made some clarifications to the directions:

Define a method named three that always returns the number 3. Also define a method named five that always returns the number 5. Neither method should take any arguments. (We know, these methods aren't especially useful. We just want to see if you know how to make a method return a particular value!)