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!

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

1 Answer

William Li
William Li
Pro Student 26,825 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!