Feature #5551
closed
Added by sawa (Tsuyoshi Sawada) over 12 years ago.
Updated over 12 years ago.
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]
なかだです。
(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はできる。
中田 伸悦
中田さんのコメントにあるような方向性(のどちらか)でいくのがよいと思います。
- Status changed from Open to Rejected
Arrayに追加するのであれ、Enumeratorで遅延評価するのであれ、この提案の根幹部分の変更になりますので、いったんrejectします。
また、思いついたrandom ideasをなんでもRubyに入れようとするのでなく、なぜそれを入れると良いのかという部分を説明していただけると採用しやすいと思います。現時点ではrdropの嬉しさがよくわからないので、Array#rdropとか採用しにくいです。
まず、ActiveSupportに入れたら、とか思っちゃいます。
Also available in: Atom
PDF
Like0
Like0Like0Like0