From: "Marcin Mielżyński" Date: 2006-03-28T21:58:55+09:00 Subject: Re: Array resizing Victor Shepelev wrote: > Maybe dumb question, but... > > I have not found anything like Array.resize, i.e. > > a = [1,2] > > a.resize(5) #=> [1,2,nil,nil,nil] > a.resize(5, 3) #=> [1,2,3,3,3] > > I can use Array.fill, but > > a.fill(3, a.size, a.size+2) > > looks a bit ugly, not? > a = [1,2,3] a += [nil] * 3 > Moreover, if I want to resize to size lesser then array is, I need slice. > a = [1,2,3,4,5] a[0..-3] Ruby 1.9 supports Array#pop taking an integer lopex