On 27.12.2007 22:18, bbiker wrote:
> On Dec 27, 4:59 am, Robert Klemme <shortcut... / googlemail.com> 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]

Well, yes.  But I don't want to.  Instead I'd rather use last= and 
first= in some circumstances much the same way as I sometimes rather use 
last and first instead of [0] and [-1].

So far the only argument against I have seen so far is the question 
about assignment to an empty array.  In that case I'd say, either raise 
an exception or silently add the element.  Have to think about this a bit.

Cheers

	robert