IRB for Interactive RuBy
You’re probably familiar with irb
, a Ruby shell, but did you know that you can instantiate it directly from code?
Your program is paused (or at least the thread in which irb
is called), allowing it to be debugged. However, its use is limited until Ruby 3.0.
Since Ruby 3.1, it has been linked to the debug gem for more advanced functionality.
Now included in the Ruby installation, it’s « easy » to find the source of a problem. Even a command line
Ruby script.
⚠️ A limitation (or bug?) when commands are chained (if you can find a way to make it work, we’d love to hear from you!). Be careful, as irb
evaluates what’s in stdin
without asking your opinion.
irb
certainly hides a lot more. Try this code several times in your console 😉.
Links to Ruby documentation for binding.irb
and IRB
.