So granted I’ve ventured over to Lisp land a bit, but these ideas still
seem like they could be useful:
array = [1, 2, 3, 4, 5]
Exists
array.first # => 1
Proposed
array.rest # => [2, 3, 4, 5]
…and/or array.tail
Granted it would be as simple as array[1…-1] but that lacks the
distinct
eloquence of most ruby syntax and it seems to be far more of a language
feature possibility.
Monkey patching it on would be trivial, yes, but I would rather avoid
that
in favor of discussing this as a possible feature.
This of course inspired by Lisp’s car/cdr or first/rest and head/tail
(of
which I don’t remember the origin.)
All interesting and such, but moot given core language change
discussions happens over on ruby-core mailing list. I think your
suggestion has merit (Hey, Im a Lisper, too!), but nothing we can really
do over here. Even better, fork ruby, add the methods, and submit a PR.
Id say it should be in Enumerable, as well. The implementation should be
dead-easy:
Someone already did, and I did actually go straight to that list. The
request is there and is about a year old so I was stirring it up a bit
after I found the report to add it.
Someone already did, and I did actually go straight to that list. The request is
there and is about a year old so I was stirring it up a bit after I found the
report to add it.