Ruby Cod中的单断点插入

2024-06-07 19:13:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图找到与python中的这些行具有相当功能的ruby代码:

import code
code.interact(local=locals())

这些行实际上是在代码中插入一个断点,并打开一个控制台,在那里我可以与任何变量交互。在

对如何在Ruby中实现这一点有什么想法吗?在


Tags: 代码import功能localcodeinteractruby断点
2条回答

您想要Pry库:

require 'pry' # gem install pry
binding.pry   # Drop into the pry console

阅读更多信息:
http://banisterfiend.wordpress.com/2011/01/27/turning-irb-on-its-head-with-pry/

另请参见:
How to use Pry with Sinatra?

在Ruby中有一个内核本地变量,它返回当前局部变量的名称。 查看文档:

ri local_variables

相关问题 更多 >

    热门问题