From: Michael Neumann Date: 2001-04-28T04:10:27+09:00 Subject: [ruby-talk:14347] Re: RCR: Array#insert Chris Moline wrote: > On Fri, Apr 27, 2001 at 11:26:37PM +0900, Yukihiro Matsumoto wrote: > > |Some people asked the same question. Is it a bad idea to provide > > |Array#insert? > > |# There is another reason - Array#[]= is not efficient for one > > |# object insertion. > > > > Sounds good. Define a behavior of Array#insert, please. > How about it takes two arguments one for the position in the array to insert and the other the object to insert?? class Array def insert(inx, obj) self[inx, 0] = obj self end end But naming it insert_before and insert_after would be easier to understand, I think. Regards Michael -- Michael Neumann merlin.zwo InfoDesign GmbH http://www.merlin-zwo.de