top | item 8498591

(no title)

gcao | 11 years ago

In pry is it possible to return something when I exit the REPL? Like this:

  def do_something
    return binding.pry

    do_something_but_does_not_work
  end

  result = do_something
  process result
It might be very convenient if I put 'return binging.pry' just before the broken code. I can interactively fix the broken code and continue run outside of current method.

discuss

order

vidarh|11 years ago

If you are explicit: "return" in a Pry session will exit pry and return the value you pass to it, just as if you are in the method itself. So e.g. "return 42" would return 42 from do_something.