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?

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

1 Answer

Steve Hunter
MOD
Steve Hunter
Treehouse Moderator 57,551 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?

Steve.