From: Matt Armstrong Date: 2002-01-24T14:25:59+09:00 Subject: Re: Array.last Weirdness Alexander Schofield writes: > Array#last= doesn't exist in 1.6 , I don't think it has been added > since. > class Array > def last= (obj) > self[length-1] = obj > end > end > Will give you the functionality you want (but I think you would need to > do array.last += ' world'). > > Just as an aside, this is a method which could save a lot of typing > in many situations when you are building up an array, it saves you > having to type arr[arr.length-1]= all over the place. Shouldn't it > be added? I don't think adding Array#last= is a bad idea, but replacing the last element of an array with a different value isn't so common. When building up an array, Array#push and Array#<< are useful though -- they append the value to the array. -- matt