ruby-on-railsrubyloopsexitpry

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.


Solution

  • To exit Pry unconditionally, type

    exit-program
    

    Edit from @Nick's comment: Also works:

    !!!