How can I use break
in a loop while using pry-debugger
that has break
function?
10.times do |i|
break if i > 2
end
This code will fail with error ArgumentError: Cannot identify arguments as breakpoint
.
Instead of using break
, you could use break()
. The parenthesis will help ruby distinguish between pry-debugger's break
, and the ruby break()
function. Your code would then look like this:
10.times do |i|
break() if i > 2
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With