Thanks. Too bad I can't use the [] indexing notation, though.

I'm starting to learn the Ruby libraries...

Ken

Jamey Cribbs wrote:
> Kenneth McDonald wrote:
>> I'm slowly doing more in Ruby (in addition to what I do in Python), 
>> as I like the cleanliness of the language. However, one thing that I 
>> really _don't_ like is the fact that an attempt to access a 
>> non-existent list item silently returns nil, rather than throwing an 
>> exception. Is there a way to make this more strict? Hashes have the 
>> same behavior, but since they can be assigned a default block, that 
>> isn't nearly so much of a problem.
>>
>> I know I could change List behavior, but there are very obvious 
>> reasons why that's a Bad Thing. I could also subclass list, but then 
>> I miss all of the syntactic niceties of lists. And both solutions 
>> impose an extra level of calling for what will be very frequent actions.
>>
>
> Array#fetch will raise an exception if the index does not exist.
>
> Jamey
>
>