On Dec 27, 4:59=A0am, Robert Klemme <shortcut... / googlemail.com> wrote:
> Hi,
>
> just today I came across a situation where I needed Array#last=3D
> because I wanted to do
>
> an_array.last +=3D 1
>
> Does anybody else see this as useful? =A0Any issues with this? =A0If 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 =3D [3, 5, 7, 11, 9, 2]
=3D> [3, 5, 7, 11, 9, 2]
irb(main):007:0> an_array.last
=3D> 2
irb(main):008:0> an_array.first
=3D> 3
irb(main):009:0> an_array[0] =3D 19
=3D> 19
irb(main):010:0> an_array[-1] =3D 1
=3D> 1
irb(main):011:0> an_array.last
=3D> 1
irb(main):012:0> an_array.first
=3D> 19
irb(main):013:0>