Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Dealing with defective code is something we all need to do from time to time. If we approach these issues in a relatively disciplined way, we can methodically corner and squash pretty much any bug that can be imagined. Debugging Ruby code tends to be a fluid process, starting with a good specification of how things should actually work, and then exercising various investigative tactics until a fix can be found. We don’t necessarily need a debugger to track down issues in our code, but we do need to use Ruby’s introspective features as much as possible, as they have the power to reveal to us exactly what is going on under the hood.
Once you get into a comfortable workflow for resolving issues in your Ruby code, it becomes more and more straightforward. If you find yourself lost while hunting down some bug, take the time to slow down and utilize the strategies we’ve gone over in this chapter. Once you get the hang of them, the tighter feedback loop will kick in and make your job much easier.