How do I step out of a loop with Ruby Pry?

前端 未结 9 1137
醉话见心
醉话见心 2020-12-22 15:11

I\'m using Pry with my Rails application. I set binding.pry inside a loop in my model to try and debug a problem. For example:

(1..100).each do          


        
9条回答
  •  一生所求
    2020-12-22 15:49

    Using gem pry-moves you can step out of loop using f (finish command)


    example:

        42: def test
        43:   3.times do |i|
     => 44:     binding.pry
        45:     puts i
        46:   end
        47:   puts :finish
        48: end
    
    [1] pry(main)> f
    0
    1
    2
    
    Frame: 0/1 method
    From: playground/sand.rb:47 main
    
        42: def test
        43:   3.times do |i|
        44:     binding.pry
        45:     puts i
        46:   end
     => 47:   puts :finish
        48: end
    

提交回复
热议问题