From: Xavier Date: 2004-04-19T05:34:09+09:00 Subject: Re: add elment on the first index of an array On Sun, 18 Apr 2004 22:21:42 +0200, Dirk Einecke wrote: > Hi. > > I have an array. Now I will add a element on the first index. I do this > like this: > > $a_foo = Array.new > $a_foo = $bar.split('/') > $a_foo = $a_foo.reverse > $a_foo << 'something' > $a_foo = $a_foo.reverse > > Is there a shorter way to do this? > > greetings > Dirk Einecke Use unshift e.g. irb(main):001:0> [1,2,3].unshift(0) => [0, 1, 2, 3] Hth