如何调试Ruby脚本

问题描述:

我从互联网上复制了以下Ruby代码并进行了一些更改,但是没有用。

I copied the following Ruby code from the Internet and made a few changes but it doesn't work.

我该怎么做才能自己调试程序?

What can I do to debug the program by myself?

使用 GitHub )。

通过以下方式安装:

$ gem install pry
$ pry

然后添加:

require 'pry'; binding.pry

进入您的程序。

0.12.2开始,没有导航命令,例如 next break 等。其他一些宝石也提供了此功能,例如,参见 pry-byedebug

As of pry 0.12.2 however, there are no navigation commands such as next, break, etc. Some other gems additionally provide this, see for example pry-byedebug.