methods that return a value
not quite sure what they're looking for here...
def parse_answer(answer, kind="string") do |answer| if kind == number answer = answer.to_i return answer end
Jennifer NordellTreehouse Staff
Hi there! Well no matter what we need to return the answer. But we also need to look if the
kind variable is equal to "number". If it is, then we need to convert it to a number before we return it. But your code is trying to compare the kind to a variable named number... not the string "number". Also, an if block needs its own end statement. Take a look:
def parse_answer(answer, kind="string") if kind == "number" answer = answer.to_i end return answer end
Here we have our function that accepts an answer and a kind. The default of kind is "string". But if we were to send in a kind of "number", then the code in the if statement would execute. In this case, it converts the answer to a number. And regardless of what else happens, we always return the answer. Hope this helps!