Ruby Ruby Loops Build a Simple Contact List Methods That Return a Value

Andrew Insley
Andrew Insley
7,014 Points

I can code to work in Workspaces but not in problem. Help???

Again, another problem where I don't really understand what the question is asking me to do. I have assumed it wants me to get an input, then convert this to a number if it is a number and then return the answer.

I have designed the code and it seems to work in Workspaces but something must be wrong because it is not being accepted as the solution.

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

1 Answer

Rachelle Wood
Rachelle Wood
15,361 Points

Hi. You are almost there. All you have to do is drop answer = gets.chomp since this is passed in somewhere else in the program before you define parse_answer.