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
A binding.pry
statement is exactly the same as a breakpoint in GDB. Such a breakpoint in GDB would be hit 100 times too.
If you only want the binding.pry
to be hit once, for the first iteration of the loop, then use a conditional on the binding.pry
like so:
(1..100).each do |i|
binding.pry if i == 1
puts i
end
You then exit the current session by just typing exit
.