如果你输入’n’,
你将在循环中进行100次,
我怎么能离开每个循环并继续从第7行继续调试而不退出循环然后自动运行保留代码,
1: require 'pry' 2: => 3: binding.pry 4: (1..100).each do |x| 5: print x 6: end 7: 8: print "hi"
解决方法
使用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"
使用break 8在第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继续该程序,它将在第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