From: Trans Date: 2007-12-29T03:23:05+09:00 Subject: Re: Add Array#first= and Array#last= to std lib On Dec 28, 6:39 am, "Robert Klemme" wrote: > 2007/12/28, Sebastian Hungerecker : > > > Robert Klemme wrote: > > > I do not see why allowing last= would make lasts(n)= necessary. > > > For consistency. I believe that any method foo= should be equivalent to the > > method foo except for the fact that it sets the value instead of getting it, > > which in this case isn't possible (without changing the language). I mean, > > that's not a major problem, but it'd feel a tad incosistent to me. > > You're right. Actually I was not aware that you could actually use an > argument with last. Thanks for pointing that out! > > And I agree, that changes the situation a bit. As a workaround you > could implicitly use the number of elements when assigning an Array > but I doubt it's a good idea. What if you wanted the last element to > be that array and not replace the last n elements? That situation > could not be distinguished. Hm... > So at least I now have an idea why last= is absent from the std lib. > So the discussion was definitively worthwhile. I see it from a different pov: Wasted Semantics. Regardless of the fact that #first and #last can take an _optional_ argument, #first= and #last= are both semantically obvious and would take up essentially no new space in the ruby "dictionary" (to use a Forth term). So, NOT having them is a waste of resources. Also, it's not inconceivable that they could provide some added value by being different form [0], [-1] by not throwing an error. T.