Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ruby

pry

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.

like image 236
ironsand Avatar asked Feb 24 '15 04:02

ironsand


1 Answers

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
like image 59
vigneshv Avatar answered Sep 22 '22 19:09

vigneshv