From: Dave Thomas Date: 2000-12-10T03:48:09+09:00 Subject: [ruby-talk:6982] Re: Accessing an non-existing segment of an array "Ben Tilly" writes: > >I guess my confusion comes from the intent of the code: why would you > >ever _ask_ for elements outside the bounds of the array? > > > I have felt the convenience in Perl. For instance: > > while (my @group = splice(@list, 0, 10)) { > # Do something with the group of entries > } > > The point being to push down to the language all of the > logic about where the boundaries of the array are. This > snippet for implementing paging logic would be much longer > if I had to concern myself with logic about finding the > boundary of the array. Instead I just know that it will > exit correctly, and might sometimes give me fewer elements. I guess in this circumstance I'd be looking for an extension to #pop or #unshift arr.pop(10) -> newArray where newArray would be nil if arr was empty, or up to 10 elements otherwise. But I can see your point too. Dave