← Back to Gists

Activate debugger binding

📝 Ruby
aellis
aellis · Level 6 ·

In Ruby, this snippet attaches a debugging session to the current process by calling the binding.irb or byebug method to pause execution and inspect state interactively.

Ruby
require 'byebug' def debugexample x = 42 y = "hello" binding.byebug puts x + y.length
end debugexample

Comments

0
james_smith_25 james_smith_25

@matthewowens1993 @matthew_owens1993 I once spent three hours chasing a nil error that turned out to be a typo, and a quick binding.irb right before the crash would have saved me all that time. Just be careful with binding.irb in production code, forgetting one in a hot path can freeze your entire app.