如何使用 Ruby Pry 跳出循环? - How do I step out of a loop with Ruby Pry?

问题:

I'm using Pry with my Rails application.我在 Rails 应用程序中使用 Pry。 I set binding.pry inside a loop in my model to try and debug a problem.我在模型的循环中设置了binding.pry以尝试调试问题。 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.当我输入quit ,它会进入下一次迭代并再次停止。 Is there a way to step out of the loop so I don't have to type quit 100 times?有没有办法跳出循环,这样我就不必键入quit 100 次?

Currently the only way I know how to get out of it is to use CTRL + C and restart the application.目前我知道如何摆脱它的唯一方法是使用CTRL + C并重新启动应用程序。


解决方案:

参考一: https://en.stackoom.com/question/XdCl
参考二: https://stackoom.com/question/XdCl
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章