Last Updated: February 25, 2016
·
377
· saghaulor

Step debug a loop for only as many iterations as you need to

I've found myself here a few times http://devopsreactions.tumblr.com/post/53831016555/stepping-a-long-loop-when-debugging

You don't have to do that, I promise.

In Ruby, you can do something like the following:

@@stop = false
def some_method_that_you_are_debugging
  too_many.times do
    debugger unless @@stop
    blah_blah
  end
end

Then when you are finished debugging and you don't want to keep running through the loop, just do the following:

@@stop = true

No more keyboard mashing.