Ryan Ryan - 7 months ago 10
Ruby Question

How do I step out of a loop with Ruby Pry?

I'm using Pry with my Rails application. I set

binding.pry
inside a loop in my model to try and debug a problem. For example:

(1..100).each do |i|
binding.pry
puts i
end


When I type
quit
, it goes to the next iteration and stops again. Is there a way to step out of the loop so I don't have to type
quit
100 times?

Currently the only way I know how to get out of it is to use CTRL+C and restart the application.

Answer

To exit Pry unconditionally, type

exit-program