Kenneth McDonald wrote: > So my question is, _in practice_, how difficult is it to track down > index-out-of-bounds-errors in Ruby? It can certainly be a godawful > problem in C, and I'm pretty sure it would be in Python, too, if > exceptions weren't thrown. And in Ruby, how does one track done where > such errors actually occur? In Python, I can simply look at the stack trace. I personally haven't had trouble with this. I thought I'd point out that you can make Ruby yell if you like. In a simple example (using only one form of the [] access call): irb(main):001:0> a = [0,1,2,3] => [0, 1, 2, 3] irb(main):002:0> a[5] => nil irb(main):003:0> class Array irb(main):004:1> alias_method :_lookup, :[] irb(main):005:1> def []( idx ) irb(main):006:2> raise "OutOfBounds" unless idx>=0 && idx<size irb(main):007:2> _lookup( idx ) irb(main):008:2> end irb(main):009:1> end => nil irb(main):010:0> a[5] RuntimeError: OutOfBounds from (irb):6:in `[]' from (irb):10 from :0 irb(main):011:0> a[3] => 3