From: Joel VanderWerf Date: 2004-04-19T06:41:11+09:00 Subject: Re: How do I insert into an array? Joel VanderWerf wrote: > Sam Roberts wrote: > >> I want to add an item just before the end: ... > Another way is to use ranges: > > irb(main):009:0> a = [1,2,3] > => [1, 2, 3] > irb(main):010:0> a[2...2] = "second last" Oops. Unless you want to calculate the length yourself, you're better off with: a[-1...-1] = "second last"