From: "Aleksi Niemelä" Date: 2000-10-25T22:13:55+09:00 Subject: [ruby-talk:5850] Re: Array#insert rehashed Dave asks for: > Could someone give me a 1 paragraph summary of why we need #insert? I hope I don't let you down by writing a couple. As an idiom Array#[pos,len]= works ok, but have couple of traps. First, it autoflattens. Second it doesn't work intuitively with negative indices. Even if Array#insert(pos, stuff) is defined to be same as Array#[pos,0]=stuff (when []= doesn't have the previous problems) it enhances code readibility: ary, other = [1,2,3], [4,5] ary[1,0] = other # vs. ary.insert(1, other) The effect is comparable to having a Array#push or Hash#fetch around. Both are used much and enhance readibility, while could be coded otherwise. - Aleksi