ironsand
ironsand

Reputation: 15141

How to use original "break" in a loop when using pry-debugger

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.

Upvotes: 8

Views: 364

Answers (1)

vigneshv
vigneshv

Reputation: 642

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

Upvotes: 9

Related Questions