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 Loops Build a Simple Contact List Methods That Return a Value

What does "Try again!" error mean?

It says my code is incorrect but does not give me any hint or indication on what part of the code is wrong as per usual. It just says "Bummer! Try Again!".

Challenge: Fill out the parse_answer method to return the answer passed in. If the kind is "number", convert answer to an integer using the to_i method before returning it. Bummer! Try again!

ask.rb
def parse_answer(answer, kind="string")
  print answer + " "
  answer = gets.chomp
  answer = answer.to_i if kind == "number"
  return answer
end

1 Answer

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

"Try again!" is just a concise feedback from the code challenge's grader, it means either there's some errors in your code, or your code didn't fully comply with the requirements of code challenge.

For this particular one, problems lie in line 2 & 3.

  print answer + " "
  answer = gets.chomp

answer is an argument to the parse_answer function, it's not supposed to be assigned a value of user input. Delete line 2 & 3 then your code should be fine.

That did it. Thank you!