如何使用 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章