From: bbiker Date: 2007-12-28T06:19:59+09:00 Subject: Re: Add Array#first= and Array#last= to std lib On Dec 27, 4:59 am, Robert Klemme wrote: > Hi, > > just today I came across a situation where I needed Array#last= > because I wanted to do > > an_array.last += 1 > > Does anybody else see this as useful?  Any issues with this?  If not > I'll open an RCR. > > Kind regards > > robert > > -- > use.inject do |as, often| as.you_can - without end There's already array#last and array#first you csn do what you want with an_array[0] and an_array[-1] irb(main):006:0> an_array = [3, 5, 7, 11, 9, 2] => [3, 5, 7, 11, 9, 2] irb(main):007:0> an_array.last => 2 irb(main):008:0> an_array.first => 3 irb(main):009:0> an_array[0] = 19 => 19 irb(main):010:0> an_array[-1] = 1 => 1 irb(main):011:0> an_array.last => 1 irb(main):012:0> an_array.first => 19 irb(main):013:0>