Feature #5551
closedEnumerable#rdrop
Description
There is Enumerable#drop(n), which drops elements on the left side, but there is no counterpart for dropping the right side. It will be convenient if there is Enumerable#rdrop(n) that drops the elements on the right side.
[1, 2, 3, 4, 5].rdrop(2) # => [1, 2, 3]
Updated by nobu (Nobuyoshi Nakada) over 13 years ago
なかだです。
(11/11/03 3:18), Tsuyoshi Sawada wrote:
There is Enumerable#drop(n), which drops elements on the left side, but there is no counterpart for dropping the right side. It will be convenient if there is Enumerable#rdrop(n) that drops the elements on the right side.
[1, 2, 3, 4, 5].rdrop(2) # => [1, 2, 3]
Enumerableは逆方向の操作を提供していませんし、無限リストも作れますから、
ArrayのメソッドにするかEnumeratorで遅延評価でもするようにしないと無理で
しょう。
--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦
Updated by sawa (Tsuyoshi Sawada) over 13 years ago
中田さんのコメントにあるような方向性(のどちらか)でいくのがよいと思います。
Updated by matz (Yukihiro Matsumoto) over 13 years ago
- Status changed from Open to Rejected
Arrayに追加するのであれ、Enumeratorで遅延評価するのであれ、この提案の根幹部分の変更になりますので、いったんrejectします。
また、思いついたrandom ideasをなんでもRubyに入れようとするのでなく、なぜそれを入れると良いのかという部分を説明していただけると採用しやすいと思います。現時点ではrdropの嬉しさがよくわからないので、Array#rdropとか採用しにくいです。
まず、ActiveSupportに入れたら、とか思っちゃいます。