From: "David A. Black" Date: 2004-06-11T20:55:21+09:00 Subject: Re: Array#rest Hi -- On Fri, 11 Jun 2004, Robert Klemme wrote: > > "Charles Comstock" schrieb im Newsbeitrag > news:Pine.LNX.4.44.0406110124410.15301-100000@earwig.int.cec.wustl.edu... > > I find myself frequently using array slice of 1..-1, to pass the rest of > an > > array onto something. While this is a reasonably concise syntax it is not > the > > most readable. I was curious if there had ever been interest in a rest > operator > > on an array? > > > > For example > > > > a = [1,2,3,4] > > a[1..-1] # -> [2,3,4] > > a.rest # -> [2,3,4] > > > > I realize this might cause a few people to write programs in a more list > > processing stance, for which the current arrays are probably not best > suited. > > However, the majority of the times I use this operator is for say reading > in a > > command as a the first arg, and passing the rest of the elements as the > > parameters, and thus it would not be a performance issue. Rest should > also have > > the same copy symantics as the 1..-1 slice. > > > > Any particular objections to this? Should I make this an RCR? > > If you want to do something about this I'd prefer a symmetric solution like > Array#head and Array#tail or Array#car and Array#cdr. I agree, though my first choice would be just to keep it as is. I'm not entirely sure why... it could just be jitters about creeping method multiplication, though I do try not to confuse RCRs in my mind with RCs :-) > Btw: is "rest" in English the same as in German? I always thought "rest" > rather means "pause" than "reminder"... s/reminder/remainder/ :-) It has several meanings (it can be equivalent to "Ruhe"), including "remainder": "While he stayed, the rest of us went home." But when you want to emphasize that everything except what remains has been destroyed, you would say, e.g., "the remains of the building". (As opposed to: "They painted the second floor but not the rest of the building.") David -- David A. Black dblack@wobblini.net