Search code examples
rubydebuggingbyebug

Make byebug stay in scope/function after running last line


Say I'm debugging a function like this

def foo {
  byebug
  x = 1+1
}

Running this, we hit the breakpoint. If I now hit "n", it runs the next line and exits the function. How can I instead remain in the function and inspect x?


Solution

  • Try finish 0.

    The finish command should step out the number of frames you specify as an argument. If you specify 0, it has special behavior and just finishes the current frame without stepping out of it.