From: Zuzzurro Date: 2005-01-26T17:25:53+09:00 Subject: Re: Array#insert implementation Il giorno mar, 25-01-2005 alle 22:23 +0100, Florian Gross ha scritto: > Zuzzurro wrote: > > > class Array > > def insert(v, i) > > [...] > > Is there a better way of doing this? > > Sure, just use Array#insert: > > irb(main):043:0> ary = [1, 2, 3]; ary.insert(1, 5); ary > => [1, 5, 2, 3] nice to see they added #insert in the 1.8 version, I'm still using 1.6 tough, so I did the following: class Array def insert(i, v) self[i,0] = v end end as suggested by Robert Klemme. Regards, Paolo.