如何从正在运行的脚本中转到 IRB 提示? [英] How do I drop to the IRB prompt from a running script?

查看:25
本文介绍了如何从正在运行的脚本中转到 IRB 提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以从正在运行的 Ruby 脚本中转到 IRB 提示吗?

Can I drop to an IRB prompt from a running Ruby script?

我想运行一个脚本,然后让它在程序中的某个点用程序的当前状态给我一个 IRB 提示,但不仅仅是通过运行 rdebug 并设置断点.

I want to run a script, but then have it give me an IRB prompt at a point in the program with the current state of the program, but not just by running rdebug and having a breakpoint.

推荐答案

你可以使用 ruby​​-debug 来访问 irb

you can use ruby-debug to get access to irb

require 'rubygems'
require 'ruby-debug'
x = 23
puts "welcome"
debugger
puts "end"

当程序到达调试器时,您将可以访问 irb.

when program reaches debugger you will get access to irb.

这篇关于如何从正在运行的脚本中转到 IRB 提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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