From: Florian Frank Date: 2006-01-12T02:55:33+09:00 Subject: Re: safe array index ? Christer Nilsson wrote: >Is it possible to catch index out of range ? > >a = [1,2] > >a[99] returns nil, I would like to get an error. > >I've tried to define a SafeArray class, but failed. > >I managed to redefine Array, but I want to have both possibilities. > > a.fetch 99 # => raises IndexError: index 99 out of array -- Florian Frank