Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChristopher Kemp
3,446 Pointsparse_answer
When I try to run this, all I get is the "Bummer: Try again!" message and so I am not even sure where I am going wrong because i can't preview what the code is doing either.
def parse_answer(answer, kind="string")
answer = gets.chomp
if kind == "number"
answer = answer.to_i
end
puts answer
end
1 Answer
William Li
Courses Plus Student 26,868 PointsCouple issues with your code.
-
answer was pass-in as the method argument, you do NOT need to assign
get.chomp
to answer. -
puts
statement doesn't generate any return value for the method.
def parse_answer(answer, kind="string")
if kind=='number'
answer = answer.to_i
end
answer
end
this should do it.
Christopher Kemp
3,446 PointsChristopher Kemp
3,446 PointsThank you very much! I guess I just was overthinking it.