From: "Aleksi Niemelä" Date: 2000-10-18T05:18:00+09:00 Subject: [ruby-talk:5652] Array#insert I was looking up how Array#insert should be called. Uh, there's none! Maybe there's some other suitable method somewhere in the middle of the other, but I didn't spot it fast. Of course ary[index,0] = stuff. But it's very annoying format, when you could be more explicit too. Besides there's always the surprise of ruby -e'a=[1,2,3]; a[1,0]=[4,5]; p a;' [1, 4, 5, 2, 3] ruby -e'a=[1,2,3]; a[1,0]=[[4,5]]; p a;' [1, [4, 5], 2, 3] lurking, and I'd expect the first example output what the second does. If there should be Array#insert we should probably make up our mind whether it should be implemented as (not any real code, just to show possible few points for debate) class Array def insert(index, *ary) self[index<+1>, 0] = <*>ary end end where <+1> is about having semantics of "insert-before/at" or "insert-after" index, and <*> if there should be some sort of autoflattening, or in some other form. I personally don't have opinion should the semantics be before or after, but I'd expect Array#insert not to autoflatten in any way. - Aleksi