Ruby Ruby Basics Ruby Syntax Method Return Values

Alejandra Valdivia
Alejandra Valdivia
7,665 Points

Hello there! I'm in the Ruby Basics class doing the methods.rb challenge and I can't seem to get the answer right...

Is there anybody who has already finished this methods.rb exercise so I can understand what I'm supposed to do? Any help will be greatly appreciated! Thanks so much!

methods.rb
def three(number1)
  print "Give me a number"
  number1 = gets.chomp
end

def five(number2)
  print "Give me a number"
  number2 = gets.chomp
end

3 Answers

Lee Vaughn
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Lee Vaughn
Treehouse Teacher

Hi Alejandra Valdivia!

The solution you used works but you could simplify it down to just:

def three
  3
end

def five
  5
end

Props on coming up with a solution!

Alejandra Valdivia
Alejandra Valdivia
7,665 Points

Hi Lee Vaughn! Wow your solution is terrific!! thank you so much!!

Lee Vaughn
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Lee Vaughn
Treehouse Teacher

Hi Alejandra Valdivia!

Are you working on this code challenge?

If so the issue is that you are doing a little more than what the text in the code challenge is asking of you. Each of those methods should return a number, 3 and 5 respectively.

If your question is about a different part of the course please share a link to the lesson or code challenge and we can dig a little deeper. :thumbsup:

Alejandra Valdivia
Alejandra Valdivia
7,665 Points

Hi Lee Vaughn!
Thank you so much for your response! I finally figured out the response after several attempts lol

Here it is, hope it helps other students: def three number1 = 3 end

def five number2 = 5 end

three five

Apparently is correct because after the system evaluated it it allowed me to continue to the next video? is this correct? I really appreciate your prompt response and your time. You're very kind. Thank you so much!

Alex