Code Snippets

Create A Toggle In .irbrc To Toggle IRB Debug Output On or Off

The Interactive Ruby Shell, or irb, is a great tool to use when debugging Ruby code. You can launch it from a shell window and quickly determine where errors in your Ruby code. Obviously irb is not always the best tool to use when debugging a large code base however for quick hints to where errors are in your Ruby code irb will save the day. One thing I noticed was sometimes when creating arrays irb would output the entire array even if you have not called for that output. So I was thinking it would be nice to be able to toggle the verbose output of arrays on or off during troubleshooting. The verbose output of irb is typically very useful so this toggle should only be used in some scenarios. Below is an explanation of how to create a toggle to turn the irb context echo on or off.