Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Kristen Kerchhoff1,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 end def five(length, width) return length - width end puts three(1, 2) puts five(7, 2)
Jason AndersTreehouse Moderator 145,692 Points
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
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."
I feel you just really over thought this one. The methods just needs to be simplified:
def three() return 3 end def five() return 5 end
Other than that... Nice work on the method syntax! :)