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

查看:169
本文介绍了如何使用Ruby Pry跳出循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Rails应用程序中使用了Pry.我在模型的循环内设置了binding.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

当我键入quit时,它将转到下一个迭代并再次停止.有没有一种方法可以退出循环,所以我不必键入quit 100次?

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?

目前,我唯一知道如何摆脱困境的方法是使用 CTRL + C 并重新启动应用程序.

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

推荐答案

要无条件退出Pry,请键入

To exit Pry unconditionally, type

exit-program

根据@Nick的评论进行编辑:也可以:

!!!

这篇关于如何使用Ruby Pry跳出循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆