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 trial

Ruby Ruby Loops Ruby Loops Loop Conditionals

Daniel Cunningham
Daniel Cunningham
21,109 Points

Problem with Loop Challenge

The code below correctly solved the challenge despite me commenting out the loops and break statements...

I was receiving the following error while entering in the uncommented version of the code earlier. "Errno::ENOENT: No such file or directory @ rb_sysopen - 1", and after commenting it out and putting "get_answer()" at the bottom, it appears to pass.

Is there are glitch happening on the back end of this challenge?

loop.rb
# Assume get_answer() is already defined

#loop do
#  answer = gets.chomp
#  get_answer(answer)
#  break if answer == "e"
#end

get_answer()

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Daniel,

You are on the right track, but you do not need the gets.chomp method because you are really getting anything. The 'imaginary' "get_answer" method is going to do that for you.

The challenges are very specific and picky, so just really pay attention to the actual wording of the question. The task just wants you to "assign the value of the get_answer() method to an answer variable." You don't need to input a value to the method.

So, the completed code should be:

loop do
  answer = get_answer()
  break if answer == "e"
end

Hope that makes sense and helps. Keep Coding! :)

Daniel Cunningham
Daniel Cunningham
21,109 Points

Thank you for clarifying! Do you know why I was receiving the "Errno::ENOENT: No such file or directory @ rb_sysopen - 1" error from earlier? I wasn't sure what that meant.

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

I actually am not sure what the error means, sorry. I haven't seen one like that. It could have been just a weird glitch with workspaces.

Daniel Cunningham
Daniel Cunningham
21,109 Points

Then, I shall wear it as a badge of honor that I broke the program! Thanks again!