0010 Binding_irb

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?

0010-binding_irb_1.png

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.

0010-binding_irb_2.png

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.

0010-binding_irb_3.png

irb certainly hides a lot more. Try this code several times in your console 😉.

0010-binding_irb_4.png

Links to Ruby documentation for binding.irb and IRB.