From: Kenneth McDonald Date: 2006-10-14T06:22:32+09:00 Subject: Re: Any way to get lists to throw exceptions on incorrect accesses? James Edward Gray II wrote: > On Oct 12, 2006, at 11:26 PM, Kenneth McDonald wrote: > >> Yep, got that one. Unfortunately, there's no equivalent for lists. > > >> array, hash = Array.new, Hash.new > => [[], {}] > >> array.fetch(999) > IndexError: index 999 out of array > from (irb):2:in `fetch' > from (irb):2 > from :0 > >> hash.fetch(:missing) > IndexError: key not found > from (irb):3:in `fetch' > from (irb):3 > from :0 > > James Edward Gray II > > Sorry, shoulda phrased more clearly; there's no solution that checks indexing on all the various list ops that uses indexing. It doesn't really matter, from what's been said, this doesn't seem to be a major issue when programming in Ruby.