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

Nick Vitsinsky
Nick Vitsinsky
7,246 Points

Why do we remove " answer = gets.chomp" if we have to "return the answer passed in"?

I don't get why?

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

1 Answer

Steve Hunter
Steve Hunter
Treehouse Moderator 57,652 Points

Hi Nick,

In this case, the answer is passed into the method. The value held by answer may have been obtained by using gets outside of this bit of code but, here, we don't need to ask the user for input as answer already has a value.

Does that make sense?