Ruby Debugging Reduce Blocks
Debugging reduce is a bit different because the memo is carried from element to element. Therefore, you want to print out the element as well as the memo.
Again, make sure that you save the memo before printing it, then return it at the end of the block. If you are using memo to build a different data structure as a part of the reduce block, inspecting the memo becomes extremely useful in converging on a good solution.
comments powered by Disqus