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

Ryan picture Ryan · Nov 4, 2011 · Viewed 63.7k times · Source

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

Evandro picture Evandro · Jun 27, 2012

To exit Pry unconditionally, type

exit-program

Edit from @Nick's comment: Also works:

!!!