On 29 Jun 2005, at 14:29, Eric Mahurin wrote: > --- jason r tibbetts <tibbettj / verdi.iisd.sra.com> wrote: > >> But back to the original suggestion that delete_at() be >> implemented the same way as shift(). The former makes it clear >> that the index in question is being removed altogether, which will >> result in a down-shifting of the array elements. shift() neither >> implies nor requires that same constraint. > > As far as I can tell, all of these should be equivalent: > > array.shift > array.delete_at(0) > array.slice!(0) $ ri Array#shift ------------------------------------------------------------ Array#shift array.shift -> obj or nil ... $ ri Array#delete_at -------------------------------------------------------- Array#delete_at array.delete_at(index) -> obj or nil ... $ ri Array#slice! ----------------------------------------------------------- Array#slice! array.slice!(index) -> obj or nil array.slice!(start, length) -> sub_array or nil array.slice!(range) -> sub_array or nil ... > Are you saying these don't have the same functionality? They take different arguments, so must parse their arguments differently and behave differently based on that. I don't see any reason to complicate matters to special case for rarely-used behaviors. There's no reason to write arr.delete_at 0 when you could write arr.shift. (slice! index calls delete_at index on the inside.) > What do you mean when you say the index is "removed altogether"? delete_at n removes from anywhere in the Array, so things must be shifted around. This is not true for shift, you just move up the pointer. (Ruby Arrays are copy-on-write.) > OT... does anybody else hate it that the String and Array API's > have suttle differences and lack methods of the other? No, I don't notice it at all. Strings aren't Arrays and Arrays aren't Strings. They only look the same if you squint really hard. -- Eric Hodel - drbrain / segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04