Carl Smith8,085 Points
Having trouble with this program
Not sure what I'm doing wrong here, just getting a "Bummer, tray again" error.
def parse_answer(answer, kind="string") print answer + " " answer = gets.chomp answer = answer.to_i if kind == "number" return answer end
Carlos Federico Puebla Larregle21,070 Points
You have to check if the "kind" variable is a number before you convert the "answer" variable to an integer, you could do it, like this:
def parse_answer(answer, kind="string") if kind == "number" answer = answer.to_i end return answer end
I hope that helps a little bit.