如果您保留类型' n',
你将在循环中进行100次,
我怎么能离开每个循环并继续从第7行继续调试而不退出循环然后自动运行剩余代码,
exit
!!!
的行为不适合我,
因为我想在退出循环后继续调试代码。
1: require 'pry'
2:
=> 3: binding.pry
4: (1..100).each do |x|
5: print x
6: end
7:
8: print "hi"
答案 0 :(得分:12)
您可以使用disable-pry
命令
答案 1 :(得分:4)
使用gem install pry-debugger
(如果你已经安装了pry-nav,你可以先卸载它。)当你来到这里时:
1: require 'pry'
2:
=> 3: binding.pry
4: (1..100).each do |x|
5: print x
6: end
7:
8: print "hi"
使用line 8
:
break 8
设置断点
[2] pry(main)> break 8
Breakpoint 1: /home/darfux/Desktop/ruby/STO/23622590.rb @ line 8 (Enabled) :
5: print x
6: end
7:
=> 8: print "hi"
然后输入continue
继续该程序,它将在line 8
点击断点:
[3] pry(main)> continue
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
Breakpoint 1. First hit.
From: /home/darfux/Desktop/ruby/STO/23622590.rb @ line 8 :
3: binding.pry
4: (1..100).each do |x|
5: print x
6: end
7:
=> 8: print "hi"
[4] pry(main)>
查看更多here