Figuring out whats wrong in Ruby can be a pain. That dynamic typing that you find so nice while writing code can sometimes work against you when reading it and troubleshooting it. What most of us end up resorting to is basically one step up from how most JS debugging happens: puts.

While this is annoying, it doesnt have to be this way. Ruby comes with a debugger, but it is slow on non-trivial applications. The best alternative is a gem called Ruby Debug, which is fast and has a bunch of goodies. I come from the GUI-debugging world of VS.NET and IDEA, so getting into Ruby Debug was a little bit of a challenge for me at first. If you come from the gdb world you should feel right at home.

Watch the Ruby Debug Basics screencast

from the screencast: fib.rb

  1. def fibn
  2. @fib_cache ||= 1, 1
  3. @fib_cachen ||= fibn-1 + fibn-2
  4. end
  5. puts fib20

Next screencast will cover debugging a Rails application.