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 trialsoufianeoucherrou
614 Pointswhat's wrong with this code?
I tried this code on Atom and it works perfect but here gave me error. any suggestion ?
def parse_answer(answer, kind="string")
print answer + " "
sawel=gets.chomp.capitalize
sawel=sawel.to_i if kind =="number"
return sawel
end
puts parse_answer("whats your name")
1 Answer
xwzotwvqqj
16,571 PointsHi Soufiane,
I don't think there is a lot wrong with your code. I tried it out in my terminal by running irb
and it is definately returning the answer. But I think the coding challenge expects something different, which is confusing, because you are doing it (almost) exactly like the teacher showed you in the previous video. So maybe this is a problem in the question itself that TreeHouse should look at sometime?
I saw someone else who was also struggling a bit with this. They eventually solved it by just doing a normal if-else to return the answer. Maybe try this? You can see their answer in this post: https://teamtreehouse.com/community/methods-that-return-a-value-code-challengeruby-loops
Jay McGavren
Treehouse TeacherJay McGavren
Treehouse TeacherAgreed, there was a lot of potential for confusion there. I have updated the challenge instructions as follows: